2. You are also right that empty structures could be extinguished. That
would demand some postprocessing with respect to the recursive nature of
such a structure. On the other hand, empty groups are for sure not very too
time consuming. So why not just live with them?

Re: Empty group counts as child.

2. You are also right that empty structures could be extinguished. That
would demand some postprocessing with respect to the recursive nature of
such a structure. On the other hand, empty groups are for sure not very too
time consuming. So why not just live with them?

2. You are also right that empty structures could be extinguished. That
would demand some postprocessing with respect to the recursive nature of
such a structure. On the other hand, empty groups are for sure not very too
time consuming. So why not just live with them?

Re: Empty group counts as child.

> On Nov 25, 2017, at 10:58 AM, nop head <[hidden email]> wrote:
>
> They totally bloat out the CSG view and make $children report the wrong number. But why create them in the first place? Why does an if that is false need to create anything?
>
The underlying reason for this is that “if” is not a language construct, it’s a built-in module. Since it’s a module, it always returns a node, even when it has no children, similar to an empty union.
Changing the contract of modules to optionally return nothing is possible. Pruning empty sub trees is also a possible post-processing step.
Another option would be to see this in connection with the old "implicit union” story, whose work-in-progress suggests allowing modules to return a (possibly empty) list of nodes, where emptyness is something we can manage in a better way: https://github.com/openscad/openscad/issues/350

Re: Empty group counts as child.

Hmm, I don't want a lazy union that outputs self intersecting objects because the slicer I use does not union them it produces the symmetric difference. I.e. each skin causes a transition from inside to outside.

My idea of a lazy union would only union things that actually do overlap and take a short when they are disjoint. It would produce the same results as now but a lot faster where ever you have multiple objects, for example when you make an array of holes. Currently the only practical way to do that is to do it in 2D and then extrude it to difference from a 3D object.

Getting rid of empty and single item groups seems like a separate issue as children and for loops don't really work properly at the moment.

> On Nov 25, 2017, at 10:58 AM, nop head <[hidden email]> wrote:
>
> They totally bloat out the CSG view and make $children report the wrong number. But why create them in the first place? Why does an if that is false need to create anything?
>The underlying reason for this is that “if” is not a language construct, it’s a built-in module. Since it’s a module, it always returns a node, even when it has no children, similar to an empty union.
Changing the contract of modules to optionally return nothing is possible. Pruning empty sub trees is also a possible post-processing step.
Another option would be to see this in connection with the old "implicit union” story, whose work-in-progress suggests allowing modules to return a (possibly empty) list of nodes, where emptyness is something we can manage in a better way: https://github.com/openscad/openscad/issues/350
-Marius

Re: Empty group counts as child.

My thought was that the CSG parser will do away with them anyway and will not
take more time than a decicated postprocessor step. But you are right, since
$children is a node count, proper semantics demands getting rid of empty
tails.

nophead wrote
>>So why not just live with them?
>
> They totally bloat out the CSG view and make $children report the wrong
> number. But why create them in the first place? Why does an if that is
> false need to create anything?

Re: Empty group counts as child.

Marius said: "The underlying reason for this is that “if” is not a language construct, it’s a built-in module. Since it’s a module, it always returns a node, even when it has no children, similar to an empty union."

My suggestion is to treat "if" as a language construct, consistent with how "if" is treated in a list comprehension.

> On Nov 25, 2017, at 10:58 AM, nop head <[hidden email]> wrote:
>
> They totally bloat out the CSG view and make $children report the wrong number. But why create them in the first place? Why does an if that is false need to create anything?
>The underlying reason for this is that “if” is not a language construct, it’s a built-in module. Since it’s a module, it always returns a node, even when it has no children, similar to an empty union.
Changing the contract of modules to optionally return nothing is possible. Pruning empty sub trees is also a possible post-processing step.
Another option would be to see this in connection with the old "implicit union” story, whose work-in-progress suggests allowing modules to return a (possibly empty) list of nodes, where emptyness is something we can manage in a better way: https://github.com/openscad/openscad/issues/350
-Marius

Re: Empty group counts as child.

Marius said: "The underlying reason for this is that “if” is not a language construct, it’s a built-in module. Since it’s a module, it always returns a node, even when it has no children, similar to an empty union."

My suggestion is to treat "if" as a language construct, consistent with how "if" is treated in a list comprehension.

> On Nov 25, 2017, at 10:58 AM, nop head <[hidden email]> wrote:
>
> They totally bloat out the CSG view and make $children report the wrong number. But why create them in the first place? Why does an if that is false need to create anything?
>The underlying reason for this is that “if” is not a language construct, it’s a built-in module. Since it’s a module, it always returns a node, even when it has no children, similar to an empty union.
Changing the contract of modules to optionally return nothing is possible. Pruning empty sub trees is also a possible post-processing step.
Another option would be to see this in connection with the old "implicit union” story, whose work-in-progress suggests allowing modules to return a (possibly empty) list of nodes, where emptyness is something we can manage in a better way: https://github.com/openscad/openscad/issues/350
-Marius

Re: Empty group counts as child.

Administrator

> On Nov 26, 2017, at 3:06 PM, nop head <[hidden email]> wrote:
>
> Yes It should be a language construct. How many other bits of language are modules? and would they benefit from not being?
>
Quite a few. The language of OpenSCAD is really quite minimal.
The language, in its entirety, as Doug has lobbied extensively for, is ripe for a redesign. Some of this is possible to do through iteration and some will eventually require us to break backwards compatibility.

Switching out if-else statements from being modules to being language constructs, while marking that switch as experimental, is a pretty low-risk endeavor. if-else is already managed by the parser, so this is mostly about separating modules from these statements on the AST level.

Admin - email* me if you need anything, or if I've done something stupid...* click on my MichaelAtOz label, there is a link to email me.Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”Fight it! http://www.ourfairdeal.org/ time is running out!

Re: Empty group counts as child.

I don't claim to grok all of the implications, and I certainly know
nothing of the implementation, but empty nodes seem useful to
represent placeholders in the "argument list" that the children
represent.

It does seem simple and consistent that every statement produces
exactly one node. Unfortunately, not always adequate - consider
the need for intersection_for(). I am not sure whether the
simplicity and consistency outweighs the flexibility of allowing
some statements to produce zero nodes (and some to produce more
than one?).

Re: Empty group counts as child.

Administrator

>
> It does seem simple and consistent that every statement produces exactly one node. Unfortunately, not always adequate - consider the need for intersection_for(). I am not sure whether the simplicity and consistency outweighs the flexibility of allowing some statements to produce zero nodes (and some to produce more than one?).
>
My view is that intersection_for() is a hack to work around exactly this.
In the work-in-progress branch for #350, intersection_for() has been deprecated: https://github.com/openscad/openscad/issues/350

That branch does break a bunch of stuff so I lost momentum implementing it as I haven’t found a good point in time to introduce such changes, or found a middle ground that maintains current behavior for existing designs.