(is this) A bug? echo seems to accept children

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

(is this) A bug? echo seems to accept children

int_i
trying to understand why my things weren't rendering... luckily I noticed I forgot a ";" after the echo statement. Simple example:

echo("hello world")
cylinder(h=3, r=2);


No errors, but the cylinder won't render.
using version 2019.05

Sent from the OpenSCAD mailing list archive at Nabble.com.

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

Re: (is this) A bug? echo seems to accept children

MichaelAtOz
Administrator
int_i wrote
I noticed I forgot a ";" after the echo statement. Simple example:

echo("hello world")
cylinder(h=3, r=2);

No errors, but the cylinder won't render.
using version 2019.05
In 2019.05 echo() is basically a null operation, it does not propagate the geometry of its children (being children because of the missing ';').

In newer versions (new release 2021.01), echo() has been enhanced, it does the echo output, but also passes any child geometry upward. And echo() can also be used in an expression, e.g. to help debug a recursive function.
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, 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.


Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, 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.
Reply | Threaded
Open this post in threaded view
|

Re: (is this) A bug? echo seems to accept children

nophead
In reply to this post by int_i
In the latest version it renders the cylinder.

On Sun, 7 Mar 2021 at 12:45, int_i <[hidden email]> wrote:
trying to understand why my things weren't rendering... luckily I noticed I forgot a ";" after the echo statement. Simple example:

echo("hello world")
cylinder(h=3, r=2);


No errors, but the cylinder won't render.
using version 2019.05

Sent from the OpenSCAD mailing list archive at Nabble.com.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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

Re: (is this) A bug? echo seems to accept children

Parkinbot
echo() can appear almost everywhere. However it is not "invisible" in code, because it can appear at the end of an expression.  

a = 20; 
cube(echo(a) a);  // OK
cube([a, a, echo(a) a] ); // OK
cube(a echo(a)); // Error
cube([a, a, a echo(a)] ); // Error


Sent from the OpenSCAD mailing list archive at Nabble.com.

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

Re: (is this) A bug? echo seems to accept children

adrianv
I think it's a little better to understand that echo in an expression context returns its child.  That is "echo(...) expr" is just equal to expr.   It's not just something you can insert anywhere.  

So
   "echo(a) b" is equal to the child b
   "echo(a)echo(b)echo(c) d" is equal to the child d
   "echo(a)" is equal to undef because the child is missing

"a echo(a)" doesn't make sense because you can't put one expression after another.  It would be like writing "a b", which is also an error.    If you change it to  "a+echo(a)" it is a syntax error, apparently because the + has higher priority than children (odd).  If you add parentheses and get "a+(echo(a))" then it parses to a+undef and gives you a warning about a sum containing an undef.


Parkinbot wrote
echo() can appear almost everywhere. However it is not "invisible" in code,
because it can appear at the end of an expression.  






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


Sent from the OpenSCAD mailing list archive at Nabble.com.

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