Subject: Goto in Common Lisp

From: Shlomi Fish <[email-masked]>
Date: Thu, 14 Mar 2002 14:16:30 +0200 (IST)

Just going thru Paul Graham On-Lisp book I found out that Common Lisp has
a prog directive that lets one write code with go-tos in them:

(prog ((a 0))
      mylabel
      (if (= (mod a 3) 0)
	  (go afterprint))
	; OmerM and Oleg - the last ")" is just for you.
      (print a)
      afterprint
      (setf a (+ a 1))
      (if (< a 20)
	  (go mylabel))
)

This code happens to be very GW-Basicish but it illustrates the point.
Problem is that I'd rather not use it for the entire function, (because
labels are not very special-looking) so I'm not sure if it's a complete
solution.

Wouldn't (label mylabel) and (goto mylabel) would have been a  better
solution (as long as one does not use recursion, of course)?

I remember that when I read a book about AI, and it taught LISP, I was
dazzled by the amount of obscure constructs, all of which could have been
more easily replaced by goto. But then again, I'm not sure it taught
Common Lisp.

Regards,

	Shlomi Fish

----------------------------------------------------------------------
Shlomi Fish        [email-masked]
Home Page:         http://t2.technion.ac.il/~shlomif/
Home E-mail:       [email-masked]

"Let's suppose you have a table with 2^n cups..."
"Wait a second - is n a natural number?"