-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
assigned values aren't accessible by child() #50
Comments
In your example, the cube is evaluated in the context in which it is instantiated, which doesn't know about the variable. |
for me this is very confusing. it seems like you basically have a module with 'side effects', i.e. you pass a variable to some module, and it modifies the variable so that it remains changed, even after the module is done. but i could be wrong, because i am having a hard time understanding what is happening. |
No, the variable should only be changed in the context of the assign statement. OpenSCAD already works this way with other transforms, like intersection(). Only things in the context of intersect are intersected. If I change my example to: module test() { test() union() { That returns an intersection of the cube and sphere. I just think "assign" should work the same way. |
oops, that was a bad example. how about: module test() { test() cube(10); |
im confused about cases like this: module test1() { module test2() { test2() cube(variable); |
I think it is clarified if you expand everything. If expanded out, your example would look like this: assign(variable=2) when it's written this way I think it's pretty clear what should be done: the final assign statement overrides the value set in the first one |
yes, but didn't someone just say on the mailing list that color(blue) should produce a blue sphere? i am sure many people would like the feature as you describe it, but i am afraid it is a bit beyond my grasp. |
if they ever implement it, i can definitely help test it. |
Ahh I see. Yes there are arguments for both sides. On the one hand, we have it the way it is currently implemented (as I most recently illustrated), and on the other hand we have the need to override what has already been done. I suppose whatever decision is made there may come to bear on this as well. |
Actually the issue of which assign overrides the other is not really related to this issue. |
Do any of you have any new thoughts on this? Since I recently refactored some of the context handling, it would make sense to look at this again. |
Closing as expected behavior; variables are lexically scoped. For dynamically scoped variables, use |
I wrote about this to the mailing list, but noone replied. Maybe it will get more attention here.
I tried doing something like this:
module test() {
assign(variable=1) child();
}
test() cube(variable);
and found that OpenSCAD complained about not knowing what variable is.
Shouldn't variable be known to the child? Otherwise the assign really isn't doing anything.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: