Setters implement generalized locations for objects
associated with some sort of mutable state. A getter operation
retrieves a value from a generalized location and the corresponding
setter operation stores a value into the location. Only the getter is
named – the setter is specified by a procedure call as below. (Dylan
uses special syntax.) Typically, but not necessarily, getters are
access operations to extract values from Yasos objects (see Yasos).
Several setters are predefined, corresponding to getters
car) is equivalent to
This implementation of setters is similar to that in Dylan(TM)
(Dylan: An object-oriented dynamic language, Apple Computer
Eastern Research and Technology). Common LISP provides similar
Returns the setter for the procedure getter. E.g., since
string-refis the getter corresponding to a setter which is actually
string-set!:(define foo "foo") ((setter string-ref) foo 0 #\F) ; set element 0 of foo foo ⇒ "Foo"
If place is a variable name,
setis equivalent to
set!. Otherwise, place must have the form of a procedure call, where the procedure name refers to a getter and the call indicates an accessible generalized location, i.e., the call would return a value. The return value of
setis usually unspecified unless used with a setter whose definition guarantees to return a useful value.(set (string-ref foo 2) #\O) ; generalized location with getter foo ⇒ "FoO" (set foo "foo") ; like set! foo ⇒ "foo"
Add procedures getter and setter to the (inaccessible) list of valid setter/getter pairs. setter implements the store operation corresponding to the getter access operation for the relevant state. The return value is unspecified.
Removes the setter corresponding to the specified getter from the list of valid setters. The return value is unspecified.