gcl-devel
[Top][All Lists]
Advanced

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

[Gcl-devel] (SETF (VALUES ...) ...) and related issues


From: Paul F. Dietz
Subject: [Gcl-devel] (SETF (VALUES ...) ...) and related issues
Date: Sat, 19 Oct 2002 17:11:29 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020408

We now can do (setf (values x y) ...), but macroexpansion show's it's not
quite right:

>(macroexpand '(setf (values x y) (f)))

(LET ((#:G1967 (MULTIPLE-VALUE-LIST (F))))
  (VALUES (SETQ X (NTH 0 #:G1967)) (SETQ Y (NTH 1 #:G1967))))
T

> (macroexpand '(setf (values (car x) (car y)) (f)))

(LET ((#:G1968 (MULTIPLE-VALUE-LIST (F))))
  (VALUES (SETQ (CAR X) (NTH 0 #:G1968))
          (SETQ (CAR Y) (NTH 1 #:G1968))))
T

>


The problem with this implementation is that he call to (F) may
modify the values of X and Y.  However, SETF is required to
evaluate the subterms needed to determine places in order, from
left to right.  This same kind of problem is occuring in some
other places (MULTIPLE-VALUE-SETQ with symbol macros, for example).

The proper solution is to use DEFINE-SET-EXPANDER and GET-SETF-EXPANSION
to produce a setf expansion that preserves the evaluation order.  If
we had those then added a setf expansion for VALUES would be
straightforward.  However, gcl doesn't support these yet.

I've added implementing these two to the Lisp Support task list.

        Paul







reply via email to

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