-
Notifications
You must be signed in to change notification settings - Fork 0
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
Function body value names not looked up in function parameter scope #4
Comments
Prolem with function is that function context is invalid after the return so evaluation must be done in the literal or the function args context must be preserved. This fixes the initial example , but won't fix anonymous modules
Fixed by ad19578 For anonymous modules you can use the following syntax. Essentially you need to create the module_literal and get a reference to it in local scope, then return a reference to the module with function call args function f (pos ,size) =
let ( m1 = module (p, s) { translate(p){cube(s);}})
module m1(pos,size);
m = f([100,50,50],[20,30,40]);
m(); |
For functions with arguments returning a module with arguments, Currently this can be done as follows: fm = function(x)
let ( m = module(y,x1 = x) cube([x1,y,20]) )
m;
(fm(30))(50); // instantiate the module returned from fm This can be shortened to fm = function(x)
module(y,x1 = x) cube([x1,y,20]); It would be possible to optimise this but this workaround seems satisfactory at the moment. |
f0 = function (s) module cube(s);
m0 = f0(10);
m0();
f1 = function () module cube([5,10,20]);
m1 = f1();
m1();
WARNING: Ignoring unknown variable 's' in file test.scad, line 1
However there is a graphical output of the cube from m1();
The text was updated successfully, but these errors were encountered: