- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
This is a conceptual question based on an answer on this forum.
The beautiful answer was given by Tom Smith to the problem "quit vs. exit",
as quoted below:
"Jason, I tend to agree, it's a red flag that the code isn't structured in
the best way. The quit/exit amounts to a goto, and if it happens more than
once in a program you're on the road to spaghetti-code hell. That's exactly
the kind of thing that lisp in particular (and functional languages in
general) were designed to avoid.
Just as deeply nested ifs are a red flag...in fact any nesting of ifs at all
raises the question, why not cond instead? It will nearly always be clearer,
simpler, and easier to debug and maintain. A red flag doesn't mean *never*
do it no matter what, it just means it should alert your instincts that
there's *got* to be a better way.
A lot of autolispers seem to be real smart about the innards of Acad without
really comprehending lisp itself...more often than not, lisp functions tend
to written in an unreadable, basic-like procedural manner that denies the
elegance and simplicity that's possible in the language.
More autolispers should search out and read some of the many available
articles on programming style written by the gurus of Common Lisp. Nearly
all of this applies directly to AutoLISP. The "real" lisp people are
remarkably consistent about what is proper and good."
I am a low level programmer - just for reaching a target -, but I want to
learn how to create the right code, to the limit of my understanding,
being proud to use such an elegant environment as LISP.
In this spirit I wonder if I can avoid the brutal exit from a while cycle
as presented in the next routine.
Here is a while cycle where the user have to decide what happens
next by choosing OK or Cancel. For OK all is right, but for Cancel my
solution was to use the local variable OK_or_Cancel which gains its
value from the evaluating of the (start_dialog) function.
All is right but I receive an error because (exit) is considered an abnormal
way to suddenly leave the program. To accomplish the idea of a smooth
leaving of program now I use the *error* function with all the necessary
saving and restoration of the system variables, as well as eliminating the
error message itself.
Well, after all, I wonder if is there any other more proper solution instead of
my beginner one. How should I structure the illustrated routine to avoid
the (exit) function?
Constantin from Romania
PS Read about me here: https://grabcad.com/constantin.stancescu
Solved! Go to Solution.