#Region workaround, can this behaviour be relied upon?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

#Region workaround, can this behaviour be relied upon?

Troberg
I have long sections of data in my code, building large arrays which, once
done, I don't want to see anymore. I noticed by coincidence that this works:

{//My big array
    bigarray=[...];
}

Likewise, I can use it to hide large blocks of code, or to organize modules
that belong together (for example, a bunch of modules defining symbols).

The non-attached {} creates a folding region in the editor, yet, as far as I
can see, has no influence at all on the code execution. Most importantly,
they don't create their own variable scope.

This is very useful, but is this as intended, or is it a "useful bug which
may not work in the future"?



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
tp3
Reply | Threaded
Open this post in threaded view
|

Re: #Region workaround, can this behaviour be relied upon?

tp3
On 16.04.20 11:27, Troberg wrote:
> This is very useful, but is this as intended, or is it
> a "useful bug which may not work in the future"?

Intended: Probably not.

However there's people using it, so there's unfortunately
no simple way to just remove it. It certainly makes things
more complicated.

It's documented in
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Scope_of_variables

But I was told we would be still allowed to change it :-).

ciao,
  Torsten.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: #Region workaround, can this behaviour be relied upon?

JordanBrown
On 4/16/2020 4:32 AM, Torsten Paul wrote:
On 16.04.20 11:27, Troberg wrote:
This is very useful, but is this as intended, or is it
a "useful bug which may not work in the future"?
Intended: Probably not.

However there's people using it, so there's unfortunately
no simple way to just remove it. It certainly makes things
more complicated.

It's documented in
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Scope_of_variables

But I was told we would be still allowed to change it :-).

I'd make an anonymous scope be a scope for variable definition purposes, as it is in most languages.

I'm not sure what the effect should be on the object tree, and if I understand correctly that answer would probably depend on what happens with "lazy union".  At the moment, I'd say that it should be equivalent to union() { }, and so yield a single child.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org