Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module /Function Parameter Passing By Reference #23

Closed
rbaumann opened this issue Sep 6, 2011 · 1 comment
Closed

Module /Function Parameter Passing By Reference #23

rbaumann opened this issue Sep 6, 2011 · 1 comment

Comments

@rbaumann
Copy link

rbaumann commented Sep 6, 2011

Would it be possible to pass parameters into modules /functions by reference? Having such a mechanism allows writing modules that can significantly enhance re-usability of components. For example imagine the following:

c = 5; // side c of the triangle
b = 4; // side b of the triangle
a = 3; // side a of the trinagle
r = 1; // radius of round triangle corners
h = 3; // hight of triangle
p = [...]; // Coordinates of corner centers and triangle's center of gravity

// create a triangle with round corners and a 2 mm diameter centered hole in each corner
difference () {
3D_TRIANGLE (s1=a,s2=b,s3=c,hi=h,p_arr=p); // module drawing 3D-triangles with rounded corners
translate (p[0] cylinder (r1=1,r2=1,h=5,center=true); // p[0] got co-ordinate of triangle A - corner
translate (p[1] cylinder (r1=1,r2=1,h=5,center=true); // p[1] got co-ordinate of triangle B - corner
translate (p[2] cylinder (r1=1,r2=1,h=5,center=true); // p[2] got co-ordinate of triangle C - corner
}

@kintel
Copy link
Member

kintel commented Feb 11, 2014

This doesn't fit into OpenSCAD's language paradigm. We're dependent on modules and functions not having side effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants