1

Does elisp have a way to jump to (goto) labels in the code, ala common lisp's go?

 (tagbody
   (setq val 2)
   (go lp)
   (incf val 3)
   lp (incf val 4)) =>  NIL
 val =>  6 

PS: This is a question about control flow, not jumping to locations in files.

2
  • The cl-lib library offers cl-tagbody (and, I presume, friends), which offers some of the common lisp primitives to do this sort of thing.
    – Dan
    Sep 22 at 16:03
  • @Dan Thanks, that's the answer.
    – HappyFace
    Sep 22 at 16:06
1

It works exactly the same, we just need to use cl-tagbody instead.

(cl-tagbody
 (setq val 2)
 (go lp)
 (incf val 3)
 lp (incf val 4))

val
6

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.