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

SETF, PUSH, POP



From:     Date:
Date: Wed, 22 Nov 79 22:54:32 GMT
Original-Date: 11/22/79 18:54:32 EDT
Subject:
    From: EB at MIT-ML
    To:   (BUG LISP) at MIT-ML
    Re:   SETF, PUSH, POP

    Why not have a general, uniform mechanism for operations thatt first
    access, compute with, and then reset (SETF) some component?  This is
    done in Interlisp with the so-called "changeword" mechanism, of which
    Interlisp "push", "pop", "pushnew", "add", and "pushlist" are instances.
    It seems better to have a general CHANGEF primitive than to special-case
    everything.  For example, in Interlisp a form

    	(change <access> <form>)

    has such an effect.  ("DATUM" within <form> stands for the old
    value.)  <access> is only evaluated once.

This is a crockashit ... you can't nest CHANGEs inside CHANGEs, since there's
no way to distinguish the DATUM referering to outside or inside CHANGE.  But
the idea is useful.  How about instead of being a form, it being a Lambda-
expression?  Thus INCREMENT becomes nothing more than a convenient way to
write (CHANGE (mumble) (lambda (x) (1+ x))) or maybe (CHANGE x (1+ x) (mumble))

  How about a DEFCHANGE macro which defines a macro to define things like
INCREMENT ...

(DEFCHANGE (INCREMENT x) (1+ x)).

(DEFCHANGE (ADDTO X N) (+ X N))	   ;Structure always comes first

[KMP doesn't like the names CHANGE and DEFCHANGE ... thinks they're ugly]

Anyway, the way the SETF stuff works it's easy for you to do any of this,
avoiding multiple-evaluations of the structure-access, and other such goblins.
I don't know how many of these are useful enough to go into the system!