From: Vladimir Zolotykh
Subject: returned value transparency
Date: 
Message-ID: <opspms8wyn4w83rv@algow.eurocom.od.ua>
Let me consider the following simple macro.

(defmacro with-slot-proxies ((&rest slot-names) obj &body body)
   (let ((pairs (mapcar #'(lambda (n)
			   `(,n (slot-value ,obj ',n)))
		       slot-names))
	(result (gensym "result")))
     `(let ,pairs
        (setq ,result (progn ,@body)) ; ***
        (setf ,@(mapcan #'reverse pairs))
        ,result)))

It has a mistake in it, e.g. in line marked ***, if BODY evaluates to  
multiple values only the
first one is returned.  How to make it to be transparent in respect to
returned value? e.g. that it returned exactly what BODY does?

-- 
Vladimir Zolotykh

From: Frank Buss
Subject: Re: returned value transparency
Date: 
Message-ID: <d4ap70$4m0$1@newsreader3.netcologne.de>
"Vladimir Zolotykh" <······@eurocom.od.ua> wrote:

> Let me consider the following simple macro.
> 
> (defmacro with-slot-proxies ((&rest slot-names) obj &body body)
>    (let ((pairs (mapcar #'(lambda (n)
>                   `(,n (slot-value ,obj ',n)))
>                  slot-names))
>      (result (gensym "result")))
>      `(let ,pairs
>         (setq ,result (progn ,@body)) ; ***
>         (setf ,@(mapcan #'reverse pairs))
>         ,result)))
> 
> It has a mistake in it, e.g. in line marked ***, if BODY evaluates to  
> multiple values only the
> first one is returned.  How to make it to be transparent in respect to
> returned value? e.g. that it returned exactly what BODY does?

(defmacro test (&body body)
  (let ((value (gensym)))
    `(let ((,value (multiple-value-list ,@body)))
       (do-what-you-want)
       (values-list ,value))))

But there might be more issues with condition handling.

-- 
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: Frank Buss
Subject: Re: returned value transparency
Date: 
Message-ID: <d4apeu$4m0$2@newsreader3.netcologne.de>
Frank Buss <··@frank-buss.de> wrote:

> But there might be more issues with condition handling.

you should write a macro for defining this kind of macros :-)

-- 
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: Helmut Eller
Subject: Re: returned value transparency
Date: 
Message-ID: <m264yfqaea.fsf@stud3.tuwien.ac.at>
"Vladimir Zolotykh" <······@eurocom.od.ua> writes:

> It has a mistake in it, e.g. in line marked ***, if BODY evaluates to
> multiple values only the
> first one is returned.  How to make it to be transparent in respect to
> returned value? e.g. that it returned exactly what BODY does?

multiple-value-prog1 

Helmut.
From: Frank Buss
Subject: Re: returned value transparency
Date: 
Message-ID: <d4aqtq$7qj$1@newsreader3.netcologne.de>
Helmut Eller <········@stud3.tuwien.ac.at> wrote:

> multiple-value-prog1 

thanks, I've learned another Lisp operator. But if a condition is 
considered as a return value, it doesn't work.

-- 
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: Barry Margolin
Subject: Re: returned value transparency
Date: 
Message-ID: <barmar-92911B.09234322042005@comcast.dca.giganews.com>
In article <············@newsreader3.netcologne.de>,
 Frank Buss <··@frank-buss.de> wrote:

> Helmut Eller <········@stud3.tuwien.ac.at> wrote:
> 
> > multiple-value-prog1 
> 
> thanks, I've learned another Lisp operator. But if a condition is 
> considered as a return value, it doesn't work.

Do you mean "if the expression signals a condition instead of 
returning"?  I think it should also work in that case.  When M-V-PROG1 
is executing the first expression, the signal will exit through it.

If you want the remaining expressions to be evaluated in that case also, 
you need to use UNWIND-PROTECT.  But the original version that just had 
the multiple-value problem didn't handle this specially, so it doesn't 
seem like a requirement.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
From: Vladimir Zolotykh
Subject: Re: returned value transparency
Date: 
Message-ID: <opspoiq61y4w83rv@algow.eurocom.od.ua>
On Fri, 22 Apr 2005 12:32:59 +0000 (UTC), Frank Buss <··@frank-buss.de>  
wrote:

> Helmut Eller <········@stud3.tuwien.ac.at> wrote:
>
>> multiple-value-prog1
>
> thanks, I've learned another Lisp operator. But if a condition is
> considered as a return value, it doesn't work.
The passage about conditon I didn't understand. What did you mean?
If a condition signalled inside the 1st form of MULTIPLE-VALUE-PROG1
why it should be any special?
>



-- 
Vladimir Zolotykh
From: Marco Antoniotti
Subject: Re: returned value transparency
Date: 
Message-ID: <wxaae.5$mi7.15708@typhoon.nyu.edu>
Vladimir Zolotykh wrote:
> Let me consider the following simple macro.
> 
> (defmacro with-slot-proxies ((&rest slot-names) obj &body body)
>   (let ((pairs (mapcar #'(lambda (n)
>                `(,n (slot-value ,obj ',n)))
>                slot-names))
>     (result (gensym "result")))
>     `(let ,pairs
>        (setq ,result (progn ,@body)) ; ***
>        (setf ,@(mapcan #'reverse pairs))
>        ,result)))
> 
> It has a mistake in it, e.g. in line marked ***, if BODY evaluates to  
> multiple values only the
> first one is returned.  How to make it to be transparent in respect to
> returned value? e.g. that it returned exactly what BODY does?
> 

(defmacro with-slot-proxies ((&rest slot-names) obj &body body)
   (let ((pairs (mapcar #'(lambda (n)
                            `(,n (slot-value ,obj ',n)))
                        slot-names))
         (result (gensym "result"))
         )
     `(let ,pairs
        (setq ,result (multiple-value-list (progn ,@body)))
        (setf ,@(mapcan #'reverse pairs))
        (values-list ,result))))

Cheers
--
Marco