The wiki documentation for assert only shows the statement form. I found
that it also works as a function in an expression. In fact it is like the
echo function in that is can be followed by an expression as well to give a
value.
I tried to update the wiki but it doesn't like my IP address.
I used it in a function by putting it in a let. I now realise I could just
put it anywhere, but why does let allow an expression on its own without an
assignment?
E.g. this gives no error or warning:
let(42);
let(1,2,3); gives:
WARNING: Ignoring duplicate variable assignment = 2
WARNING: Ignoring duplicate variable assignment = 3
which is puzzling. It behaves as if it assigns to an anonymous variable.
On 22.01.19 23:40, nop head wrote:
The wiki documentation for assert only shows the statement form. I
found that it also works as a function in an expression. In fact it is
like the echo function in that is can be followed by an expression as
well to give a value.
Assert is a parser passed. The parser it self is GNU/Bison based. This
sometimes leads to very interesting - but also very consistent -
consequences.
E.g. this gives no error or warning:
let(42);
We can always add a warning, which seams like a sensible thing to do in
that case.
I will dwell a bit on that and then get to work.
let(1,2,3); gives:
WARNING: Ignoring duplicate variable assignment = 2
WARNING: Ignoring duplicate variable assignment = 3
which is puzzling. It behaves as if it assigns to an anonymous variable.
I would not call it anonymous variable, it is really "" as in empty
string as the variable name.
Isn't the let thing a syntax error? I.e. the arguments to let should be
assignment statements with name = expression, not just an expression. let(a
42), let(a =) and let(=42) are all syntax errors as expected.
On Wed, 23 Jan 2019 at 12:15, Michael Frey michael.frey@gmx.ch wrote:
On 22.01.19 23:40, nop head wrote:
The wiki documentation for assert only shows the statement form. I found
that it also works as a function in an expression. In fact it is like the
echo function in that is can be followed by an expression as well to give a
value.
Assert is a parser passed. The parser it self is GNU/Bison based. This
sometimes leads to very interesting - but also very consistent -
consequences.
E.g. this gives no error or warning:
let(42);
We can always add a warning, which seams like a sensible thing to do in
that case.
I will dwell a bit on that and then get to work.
let(1,2,3); gives:
WARNING: Ignoring duplicate variable assignment = 2
WARNING: Ignoring duplicate variable assignment = 3
which is puzzling. It behaves as if it assigns to an anonymous variable.
I would not call it anonymous variable, it is really "" as in empty string
as the variable name.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org