[Top][All Lists]

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

Re: [Chicken-users] macrolet

From: Lui Fungsin
Subject: Re: [Chicken-users] macrolet
Date: Fri, 7 Mar 2008 12:56:50 -0800

Hi Graham,

Thanks for the reply. But it wouldn't do it for me because I'm trying
to capture a binding at macro expansion time, not run runtime.

Use case : (to support CL like (return-from) clause with call/cc)

(define-macro (defun name args . body)
  (with-gensyms (return)
   `(define ,name
      (lambda ,args
         (lambda (,return)
           (macrolet ((return-from (proc value)
                       ;; ignore proc name
                       (,return value)))

;; silly example
(defun guess (x)
          (if (eq x 7)
              (return-from guess 'you-win))

On 3/7/08, Graham Fawcett <address@hidden> wrote:
> On Fri, Mar 7, 2008 at 1:11 PM, Lui Fungsin <address@hidden> wrote:
> > Hi,
> >
> >  Is there a macrolet (CL style old school lexically scoped macro) for 
> > chicken?
> No macrolet, but you can use CL-style macros in Chicken. They just
> have to be defined at the toplevel, not in a macrolet. You can do
> variable capture as usual in CL.
> (define-macro (foo n) `(+ ,n local-name))
> (let ((local-name 100)) (print (foo 25)))
> should print "125".
> Graham

reply via email to

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