The assert message can be an expression, so you could also separate out
the informative content from check_valid into another function and call it
to provide the second argument to assert.
On Tue, 26 Mar 2019 at 00:14, adrianv avm4@cornell.edu wrote:
nophead wrote
function do_something(x,y,mode) =
assert(check_valid(mode,"mode",
["fast","slow","big","tall","purple"]),
"bad mode")
My initial reaction was that this doesn't solve the problem, since the
actual error message text says "bad mode" instead of actually giving the
informative content. But in fact it might actually be better than the
status quo if the check_valid function displays its error in red text so it
looks like part of the error message. I'd call it a hack, but a decent
one.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
nophead wrote
The assert message can be an expression, so you could also separate out
the informative content from check_valid into another function and call it
to provide the second argument to assert.
I can't think of a reason this would be useful. I don't want to write:
assert(check_valid(parameter, big_long_list), generate_message(parameter,
parametername, big_long_list))
It means repeating code, which was what I wanted to avoid. I suppose
let( result = check_valid(......) )
assert(result[0],result[1])
would be an option that gets the message entirely into the assert().
--
Sent from: http://forum.openscad.org/
Yes, or put the assert into check_valid() and rely on the the stack trace
to know where it is called from.
On Tue, 26 Mar 2019 at 09:52, adrianv avm4@cornell.edu wrote:
nophead wrote
The assert message can be an expression, so you could also separate out
the informative content from check_valid into another function and call
it
to provide the second argument to assert.
I can't think of a reason this would be useful. I don't want to write:
assert(check_valid(parameter, big_long_list), generate_message(parameter,
parametername, big_long_list))
It means repeating code, which was what I wanted to avoid. I suppose
let( result = check_valid(......) )
assert(result[0],result[1])
would be an option that gets the message entirely into the assert().
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
nophead wrote
Yes, or put the assert into check_valid() and rely on the the stack trace
to know where it is called from.
If I do this then I need to use a dummy variable when I call assert, which
was basically the whole thing I was trying to work around. If I could
define my own "function" that works like assert that would be the natural
way to do it, but assert is not a function and it works in a fashion that is
different from user definable commands. If it's basically impossible to
avoid dummy variables then we should propose a dummy variable mechanism be
added to OpenSCAD.
--
Sent from: http://forum.openscad.org/
I don't understand where you need a dummy variable?
On Tue, 26 Mar 2019 at 12:03, adrianv avm4@cornell.edu wrote:
nophead wrote
Yes, or put the assert into check_valid() and rely on the the stack trace
to know where it is called from.
If I do this then I need to use a dummy variable when I call assert, which
was basically the whole thing I was trying to work around. If I could
define my own "function" that works like assert that would be the natural
way to do it, but assert is not a function and it works in a fashion that
is
different from user definable commands. If it's basically impossible to
avoid dummy variables then we should propose a dummy variable mechanism be
added to OpenSCAD.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
function check(x) = assert(x >= 0, str(x, " is not a square")) x;
function do_something(x) = sqrt(check(x));
echo(do_something(-4));
ERROR: Assertion '(x >= 0)' failed: "-4 is not a square" in file tests,
line 2
TRACE: called by 'check', in file tests, line 4.
TRACE: called by 'sqrt', in file tests, line 4.
TRACE: called by 'do_something', in file tests, line 6.
TRACE: called by 'echo', in file tests, line 6.
On Tue, 26 Mar 2019 at 12:05, nop head nop.head@gmail.com wrote:
I don't understand where you need a dummy variable?
On Tue, 26 Mar 2019 at 12:03, adrianv avm4@cornell.edu wrote:
nophead wrote
Yes, or put the assert into check_valid() and rely on the the stack
trace
to know where it is called from.
If I do this then I need to use a dummy variable when I call assert, which
was basically the whole thing I was trying to work around. If I could
define my own "function" that works like assert that would be the natural
way to do it, but assert is not a function and it works in a fashion that
is
different from user definable commands. If it's basically impossible to
avoid dummy variables then we should propose a dummy variable mechanism be
added to OpenSCAD.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Generally I think it's cryptic code and bad practice to mix the error
checking in with the computation, though to be honest, the example you have
below isn't terrible.
But in the case I was pondering, we are checking validity of user input, not
doing a computation. The subsquent computation may be quite complex, and
there's no assignment that it makes sense to entangle the check with. So
the code will end up looking like:
dummy = check_parameter(parameter, 'parameter',
["long","list","of","options"]),
somewhere in the let() statement. I mean, I guess it could be
renamed_parameter = check_parameter(....),
and the check_parameter function returns the parameter value. But being
compelled to rename all the parameters isn't ideal either.
nophead wrote
function check(x) = assert(x >= 0, str(x, " is not a square")) x;
function do_something(x) = sqrt(check(x));
echo(do_something(-4));
ERROR: Assertion '(x >= 0)' failed: "-4 is not a square" in file tests,
line 2
TRACE: called by 'check', in file tests, line 4.
TRACE: called by 'sqrt', in file tests, line 4.
TRACE: called by 'do_something', in file tests, line 6.
TRACE: called by 'echo', in file tests, line 6.
On Tue, 26 Mar 2019 at 12:05, nop head <
nop.head@
> wrote:
I don't understand where you need a dummy variable?
--
Sent from: http://forum.openscad.org/
Hello List,
when i update my old OpenSCAD Linux Appimage to the new RC4 Release
Appimage i miss a feature.
When i have rendered a object and double click on the yellow surface in
the old version the center of the camera moved exactly to that point of
the surface. In the new version nothing happens.
Is this feature gone ? Is there a way to enable it ? Is this a bug ?
Best reguards
Corpsman
It still works on Windows, so looks like a bug.
On Wed, 27 Mar 2019 at 18:49, corpsman corpsman@corpsman.de wrote:
Hello List,
when i update my old OpenSCAD Linux Appimage to the new RC4 Release
Appimage i miss a feature.
When i have rendered a object and double click on the yellow surface in
the old version the center of the camera moved exactly to that point of
the surface. In the new version nothing happens.
Is this feature gone ? Is there a way to enable it ? Is this a bug ?
Best reguards
Corpsman
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
On 27.03.19 20:06, nop head wrote:
It still works on Windows, so looks like a bug.
Yes, but unfortunately it's a bit unclear what's wrong. Someone
tried to get it working again but there seems to be some driver
issues too -> https://github.com/openscad/openscad/pull/2466
ciao,
Torsten.