[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"break" and "continue" in Emacs Lisp

From: Herbert Euler
Subject: "break" and "continue" in Emacs Lisp
Date: Wed, 07 Dec 2005 21:44:09 +0800


I don't know how to write an Emacs Lisp program that's equal
to the following C program, because of break and continue:

   i = 0;
   while (i++ < 100)
       if (i == 25)
       else if (i == 75)

For break, I now write it in this way:

   (let ((i 0))
     (while (and (< i 100) (not (eq i 75)))
       () ; operations here
       (setq i (1+ i))))

Perhaps catch and throw also work.

For continue, this can work:

   (let ((i 0))
     (while (< i 100)
       (if (not (eq i 25))
           () ; operations here
       (setq i (1+ i))))

I don't think this is clear and straightforward. Is there any better
solution? Is there no goto in Emacs Lisp?

Thanks in advance.

Guanpeng Xu

Express yourself instantly with MSN Messenger! Download today it's FREE!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]