discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

#Region workaround, can this behaviour be relied upon?

T
Troberg
Thu, Apr 16, 2020 9:27 AM

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/

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/
TP
Torsten Paul
Thu, Apr 16, 2020 11:32 AM

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.

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.
JB
Jordan Brown
Thu, Apr 16, 2020 6:20 PM

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.

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.