From: Joel Reymont
Subject: with-slots in AllegroCL 7
Date: 
Message-ID: <1108209260.014163.230810@c13g2000cwb.googlegroups.com>
Folks,

Please take a look at
http://www.franz.com/support/documentation/7.0/ansicl/dictentr/with-slo.htm


1. I didn't know you could (defmethod (setf thing-x) :before (new-x
(thing thing)) ... Is this portable? Seems an amazing discovery to me.

2. What is the point of (thing-x thing) in this method? Why not just
thing-x?

    Thanks in advance, Joel

From: Edi Weitz
Subject: Re: with-slots in AllegroCL 7
Date: 
Message-ID: <uu0ohdgac.fsf@agharta.de>
On 12 Feb 2005 03:54:20 -0800, "Joel Reymont" <······@gmail.com> wrote:

> 1. I didn't know you could (defmethod (setf thing-x) :before (new-x
> (thing thing)) ... Is this portable? Seems an amazing discovery to
> me.

Yes, it is.

> 2. What is the point of (thing-x thing) in this method? Why not just
> thing-x?

Because you can have several different methods specializing on
different types.

  * (defparameter *foo* (make-hash-table))

  *FOO*
  * (defmethod foo (key)
      (gethash key *foo*))
  ; Compiling LAMBDA (PCL::.PV-CELL. PCL::.NEXT-METHOD-CALL. KEY): 
  ; Compiling Top-Level Form: 

  #<STANDARD-METHOD FOO (T) {58353085}>
  * (defmethod (setf foo) (new-value key)
      (setf (gethash key *foo*) new-value))
  ; Compiling LAMBDA (PCL::.PV-CELL. PCL::.NEXT-METHOD-CALL. NEW-VALUE KEY): 
  ; Compiling Top-Level Form: 

  #<STANDARD-METHOD (SETF FOO) (T T) {582EAB5D}>
  * (defmethod (setf foo) :before (new-value (key symbol))
      (format t "About to use symbol ~S as a key~%" key))
  ; Compiling LAMBDA (PCL::.PV-CELL. PCL::.NEXT-METHOD-CALL. NEW-VALUE KEY): 
  ; Compiling Top-Level Form: 

  #<STANDARD-METHOD (SETF FOO) :BEFORE (T SYMBOL) {583BF235}>
  * (setf (foo 1) 'bar)

  BAR
  * (foo 1)

  BAR
  T
  * (setf (foo 'baz) 'quux)
  About to use symbol BAZ as a key
  QUUX

If you just write NEW-VALUE instead of (NEW-VALUE <something>) it's
equivalent to (NEW-VALUE T) where T is the union of all types.

Get a copy of Keene's classic book[1] if you haven't read it already.
Maybe there are more pleasant surprises waiting for you... :)

Cheers,
Edi.

[1] Sonya Keene: Object-oriented Programming in Common Lisp
                 A Programmer's Guide to CLOS.

-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: Joel Reymont
Subject: Re: with-slots in AllegroCL 7
Date: 
Message-ID: <1108229490.881099.27040@g14g2000cwa.googlegroups.com>
Mea culpa, I should pay more attention. I missed thing-x being an
accessor :-). Thanks for the explanation, Edi!