Loading ...
Sorry, an error occurred while loading the content.

Goto in Common Lisp

Expand Messages
  • Shlomi Fish
    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
    Message 1 of 1 , Mar 14, 2002
    • 0 Attachment
      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 shlomif@...
      Home Page: http://t2.technion.ac.il/~shlomif/
      Home E-mail: shlomif@...

      "Let's suppose you have a table with 2^n cups..."
      "Wait a second - is n a natural number?"
    Your message has been successfully submitted and would be delivered to recipients shortly.