discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

reporting errors and warnings

NH
nop head
Tue, Mar 26, 2019 7:02 AM

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")

<function calculation> ;

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

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") > > > > <function calculation> > > ; > > 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 >
A
adrianv
Tue, Mar 26, 2019 9:51 AM

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/

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/
NH
nop head
Tue, Mar 26, 2019 10:58 AM

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

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 >
A
adrianv
Tue, Mar 26, 2019 12:02 PM

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/

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/
NH
nop head
Tue, Mar 26, 2019 12:05 PM

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

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 >
NH
nop head
Tue, Mar 26, 2019 7:47 PM

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

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 >> >
A
adrianv
Tue, Mar 26, 2019 9:20 PM

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?

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 &lt; > nop.head@ > &gt; wrote: > >> I don't understand where you need a dummy variable? >> -- Sent from: http://forum.openscad.org/
C
corpsman
Wed, Mar 27, 2019 6:49 PM

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

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
NH
nop head
Wed, Mar 27, 2019 7:06 PM

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

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 >
TP
Torsten Paul
Wed, Mar 27, 2019 7:09 PM

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.

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.