guile-user
[Top][All Lists]
Advanced

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

Re: Please explain different macros


From: Marius Vollmer
Subject: Re: Please explain different macros
Date: 30 Apr 2001 17:33:42 +0200
User-agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7

Sergey Dolin <address@hidden> writes:

> This example ready to run will show what i mean.
> 
> #!/usr/local/bin/guile -s
> !#
> 
> (define (gen)
>   (list (list 'func (getenv "QUERY_STRING"))
>               (list 'time (cdr (gettimeofday)))))

You need to quote (getenv ...) and (cdr (gettimeofday)) as well, like so

    (define (gen)
      (list (list 'func '(getenv "QUERY_STRING"))
            (list 'time '(cdr (gettimeofday)))))

However, I suggest you write the code like so:

    (define-macro (http:let bindings . body)
      `(let (,@bindings
             (func (getenv "QUERY_STRING"))
             (time (cdr (gettimeofday))))
         ,@body))

    (do ((i 0 (1+ i)))
        ((>= i 3))
      (putenv (format #f "QUERY_STRING=func=~A" i))
      (http:let ((a 1))
        (format #t "i=~A func=~S time=~A\n" i func time)))

This avoids the use of `procedure->memoizing-macro', which should not
be used by application programs.

Where did you learn about `procedure->memoizing-macro'?  Why did you
use it instead of `define-macro'?



reply via email to

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