help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: elisp how to return directly from a function


From: David Kastrup
Subject: Re: elisp how to return directly from a function
Date: Fri, 30 Jun 2006 13:06:43 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

"lalit mohan tripathi" <lalit.tripathi@gmail.com> writes:

> Hi Everyone,
>  
>     Could anyone explain me how I can directly return from a defun in elisp.
>  
>     basically I have following type of code:
>  
>     ......... body of defun ............
>     ..........................................
>     (if condition01
>             (return 10)  ; return from this defun with value 10
>          t)
>   
>     .......... rest body of defun ....
>    ...........................................

If you really must:

(defun whatever ()
  (catch 'return
    (... body of defun ...
       (if condition01
           (throw 'return 10))
       ... rest body of defun ...
)))

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum


reply via email to

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