guile-user
[Top][All Lists]
Advanced

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

Re: Please explain different macros


From: Sergey Dolin
Subject: Re: Please explain different macros
Date: Sat, 28 Apr 2001 17:11:03 +0600
User-agent: Mutt/1.2.5i

> >   I want cgi respond looks like
> >   (http:let ((v foo)
> >              (w bang))
> >     (http:respond
> >             (html:page
> >                ... and go on.
> >   where http:let makes bindings for variables from QUERY_STRING (as PHP
> >   does). But memoizing macro remembers QUERY_STRING in time of first
> >   evalution.
> Can you show the definition of http:let? 
(execuse me, if i post the message twice. I new with mutt and its mailing-list
handling)

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)))))

(define http:let
  (procedure->memoizing-macro
  ;(procedure->macro
        (lambda (exp env)
          `(let (,@(cadr exp)
                          ,@(gen))
                 ,@(cddr exp)))))

(let ((i 0))
  (while (< i 3)
                 (putenv (format #f "QUERY_STRING=func=~A" i))
                 (http:let ((a 1))
                                   (display (format #f "i=~A gen=~A func=~A 
time=~A\n"
                                                          i (gen) func time)))
                 (set! i (+ i 1))))

I see what (gen) is evaluted once in time of apply (procedure->*) and
couldn't resolve the problem. Now i have to used ugly c-like forms
(let ((func (http:get-param 'var-name))
       ...)
           ...)

-- 
Mutt/1.2.5i [Linux 2.2.18 i486 Digial HiNote] via Qmail-1.03



reply via email to

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