I do it frequently despite (1) may be confusing to others (2) can easily hide errant logic (e.g. (DO THIS) returns nil so (DO THIS ALSO) is not realized).
tl;dr: Be careful; judicious.
Apart from potentially reducing the readability of the code for those unfamiliar with the structure, I also find it a useful technique in certain circumstances, but the disadvantage of becoming too accustomed to writing code in this way becomes apparent when you discover that other languages don't support short-circuit evaluation... :lol:
It seems like it has the advantage of avoiding the progn in the if-condition-progn method.
(and
(CONDITIONAL STATEMENT)
(progn
(DO THIS)
(DO THIS ALSO)
)
)
If one of the "do this" expressions returns nil, the next expressions won't evaluate.
It even seems like it can serve as a form of error trapping.
This may or may not be good depending on the application.
Any comments/pitfalls/alternates to this method?
This may or may not be good depending on the application.You just must know what you are doing, so that sounds dumb for me - sorry.
Sorry for the lengthy answer, I just find your threads interesting. :nerdystraight:
Conversations like this is how I earned a t-shirt from some members. But seriously, every language has it's shortcuts but more often then not you are better off avoiding them most times.
(defun foo (/)
;; FOO this is a very useful function for doing something hard
;;
;; ARGS
;; argument1 : string
;; argument2 : list
;;
;; RETURN
;; list
Ben,
If you don't mind stepping back into the past you may find this interesting.
http://www.theswamp.org/index.php?topic=13046.msg158557#msg158557
Probably off topic, but something like this is much more legible to me for picking multiple points.Code - Auto/Visual Lisp: [Select]
Guys, you missed the point - my example was not about prompting user for a points, but to visualise how the evaluations work, based on the user input.Yes, I know. But are you starting to get my point (ronjonp and I just took your thread away from you by discussing a better getpoint procedure -i.e. the `whys' have started)?
I just find getpoint function an easy way to return a value or nil (by using only the mouse).
Yes, I know. But are you starting to get my point (ronjonp and I just took your thread away from you by discussing a better getpoint procedure -i.e. the `whys' have started)?
But what about the grdraw feature?
But what about the grdraw feature?
That was just a recursive play. :tongue2:
...
But what about the grdraw feature?
That was just a recursive play. :tongue2:
...
My getpointy is recursive...?
Awe (*sadface*)? You don't want mine in your archive?