Subject: Re: CL Performance/Syntax of IF-THEN-ELSE
From: rpw3@rpw3.org (Rob Warnock)
Date: Fri, 04 Nov 2005 22:31:41 -0600
Newsgroups: comp.lang.lisp
Message-ID: <LcmdnWpaid8wqPHenZ2dnUVZ_tednZ2d@speakeasy.net>
Tayssir John Gabbour <tayss_temp2@yahoo.com> wrote:
+---------------
| Oh, and keep in mind that many people prefer the following style
| instead, as it probably makes intention clearer:
| 
| (defun RELEASER ()
|   (when (= (length EXT:*ARGS*) 0)
|     (format t "~%~A~%" "Nope, No Command Line Args Were Provided")
|     (show-usage)
|     (return-from RELEASER))
| 
|   (format t "~%~A~%" "Yep, We've Got Command Line Args")
|   (format t "~%~A~%" "Processing Args...")
|   ;; more stuff...
|   )
+---------------

If the body of both branches is multiple expressions, I'll just use COND:

 (defun RELEASER ()
   (cond
     ((= (length EXT:*ARGS*) 0)
      (format t "~%~A~%" "Nope, No Command Line Args Were Provided")
      (show-usage))
     (t
      (format t "~%~A~%" "Yep, We've Got Command Line Args")
      (format t "~%~A~%" "Processing Args...")
      ;; more stuff...
      )))

This also avoid the nasty mid-function GOTOs [yes, RETURN-FROM is
a kind on constrained GOTO], which tend to bite you later after the
function has grown a bit...


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607