discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

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

I
int_i
Sun, Mar 7, 2021 12:45 PM

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: http://forum.openscad.org/

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: http://forum.openscad.org/
M
MichaelAtOz
Sun, Mar 7, 2021 1:22 PM

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: http://forum.openscad.org/

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: http://forum.openscad.org/
NH
nop head
Sun, Mar 7, 2021 1:22 PM

In the latest version it renders the cylinder.

On Sun, 7 Mar 2021 at 12:45, int_i ayal.s@hotmail.com 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 http://forum.openscad.org/
at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

In the latest version it renders the cylinder. On Sun, 7 Mar 2021 at 12:45, int_i <ayal.s@hotmail.com> 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 <http://forum.openscad.org/> > at Nabble.com. > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
P
Parkinbot
Sun, Mar 7, 2021 1:55 PM

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/

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/
A
adrianv
Sun, Mar 7, 2021 4:32 PM

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

Discuss@.openscad

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 > Discuss@.openscad > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org -- Sent from: http://forum.openscad.org/