Quit or Exit function?

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

Quit or Exit function?

jon_bondy
Is there any way to say "if these parameters are bad, quit immediately"?

Jon

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

Re: Quit or Exit function?

tp3
Von: jon <[hidden email]>
> Is there any way to say "if these parameters are bad, quit immediately"?
>
Currently there is no such thing (except implementing it manually using flags).

There is a request to add something like assert() in:

  https://github.com/openscad/openscad/issues/381

which is a bit awkward to implement as it would be useful to handle both
functions and modules.

ciao,
  Torsten.

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

Re: Quit or Exit function?

Neon22
I had an issue like this in a Customizer script where users could choose values that could make a nonsense result. Because of the lack of a feedback or reporting loop, I chose to detect the conditoin and replace the generated object with a text object containing a message.

So I executed normally but exposed a different object.
Reply | Threaded
Open this post in threaded view
|

Re: Quit or Exit function?

MichaelAtOz
Administrator
Yeh, but it would be handy to have something deep in your code like

exit("you idiot!");
Admin - email* me if you need anything,
or if I've done something stupid...
* 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.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
Reply | Threaded
Open this post in threaded view
|

Re: Quit or Exit function?

MichaelAtOz
Administrator
In reply to this post by tp3
tp3 wrote
which is a bit awkward to implement as it would be useful to handle both
functions and modules.
Add an option to my theoretical echof() - who's name can be just echo() but proposed within functions. And echo() the module too of course.

echo("You idiot!", $exit=true);
// $exit, to try to reduce backward compatibility conflict with normal variable names.
Admin - email* me if you need anything,
or if I've done something stupid...
* 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.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
Reply | Threaded
Open this post in threaded view
|

Re: Quit or Exit function?

G. Wade Johnson
On Mon, 31 Aug 2015 20:32:19 -0700 (MST)
MichaelAtOz <[hidden email]> wrote:

> tp3 wrote
> > which is a bit awkward to implement as it would be useful to handle
> > both functions and modules.
>
> Add an option to my theoretical  echof()
> <https://github.com/openscad/openscad/issues/741>   - who's name can
> be just echo() but proposed within functions. And echo() the module
> too of course.
>
> echo("You idiot!", $exit=true);
> // $exit, to try to reduce backward compatibility conflict with normal
> variable names.

I would prefer an exit() function, or, if we want a message a different
function like die() or fatal().

I really don't like functions/methods/subroutines with flag parameters.

G. Wade

> -----
> 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. This work
> is published globally via the internet. :) Inclusion of works of
> previous authors is not included in the above.
>
> The TPP is no simple “trade agreement.”   Fight it!
> http://www.ourfairdeal.org/ --
> View this message in context:
> http://forum.openscad.org/Quit-or-Exit-function-tp13659p13673.html
> 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


--
Always hold a grudge. Keeps the memory sharp. -- Hagar the Horrible

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

Re: Quit or Exit function?

MichaelAtOz
Administrator
G. Wade Johnson wrote
I would prefer an exit() function, or, if we want a message a different
function like die() or fatal().

I really don't like functions/methods/subroutines with flag parameters.
True, I was trying an extra push for echof() ;) ...
Admin - email* me if you need anything,
or if I've done something stupid...
* 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.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!