You can associate arbitrary properties with any procedure.
Each property is a (
value)-pair. Usually the
key is a symbol, but it can be any object.
The system uses certain internal properties:
'name refers to the name used when a procedure is printed;
'emacs-interactive is used to implement Emacs
'setter is used to associate a
Get the property value corresponding to the given
prochas no property with the given
default(which defaults to
Associate the given
To change the print name of the standard
+ procedure (probably
not a good idea!), you could do:
(set-procedure-property! + 'name 'PLUS)
Note this only changes the name property used for printing:
+ ⇒ #<procedure PLUS> (+ 2 3) ⇒ 5 (PLUS 3 4) ⇒ ERROR
As a matter of style, it is cleaner to use the
form, as it is a more declarative interface.
nameas a compound procedure consisting of the specified
methods, with the associated properties. Applying
nameselect the "best"
method, and applies that. See the following section on generic procedures.
For example, the standard
vector-refprocedure specifies one method, as well as the
setterproperty:(define-procedure vector-ref setter: vector-set! (lambda ((vector :: <vector>) (k :: <int>)) (invoke vector 'get k)))