diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-12-30 02:42:18 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-12-30 02:42:18 -0800 |
commit | 422eda12b8a931039a5bf613a8c260c3d6853403 (patch) | |
tree | a24ace5c0fd241dc5dfca5b6db21cffdcd1f741d /txr.1 | |
parent | fb7a02f021e153fa6769a5e47dda303560dfd8ff (diff) | |
download | txr-422eda12b8a931039a5bf613a8c260c3d6853403.tar.gz txr-422eda12b8a931039a5bf613a8c260c3d6853403.tar.bz2 txr-422eda12b8a931039a5bf613a8c260c3d6853403.zip |
New methods rplaca and rplacd.
* eval.c (eval_init): Register rplaca and rplacd using new
rplaca_s and rplacd_s symbol variables.
* lib.c (rplaca_s, rplacd_s): New symbol variables.
(rplaca): Handle struct object via rplaca method, if it has
one, otherwise lambda-set, if it has that, or else error
out.
(rplacd): Handle struct object via rplacd method.
* lib.h (rplaca_s, rplacd_s): Declared.
* txr.1: Documented rplaca and rplacd methods.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 66 |
1 files changed, 66 insertions, 0 deletions
@@ -25477,6 +25477,14 @@ The return value of .code lambda-set is ignored. +Note: the +.code lambda-set +method is also used by the +.code rplaca +function, if no +.code rplaca +method exists. + .TP* Example The following defines a structure with a single instance @@ -25604,6 +25612,64 @@ if the object is considered to denote an empty sequence. Otherwise it should either return that object itself, or else return the sequence which that object represents. +.coNP Methods @ rplaca and @ rplacd +.synb +.mets << object .(rplaca << new-car-value ) +.mets << object .(rplacd << new-cdr-value ) +.syne +.desc +If a structure type defines the methods +.code rplaca +and +.code rplacd +then, respectively, the +.code rplaca +and +.code rplacd +functions will use these methods if they are applied to instances of that type. + +That is to say, when the function call +.cblk +.meti (rplaca < o << v ) +.cble +is evaluated, and +.meta o +is a structure type, the function inquires whether +.meta o +supports a +.code rplaca +method. If so, then, effectively, +.cblk +.meti << o . (rplaca << v) +.cble +is invoked. The return value of this method call is ignored; +.code rplaca +returns +.metn o . +The analogous requirements apply to +.code rplacd +in relation to the +.code rplacd +method. + +Note: if the +.code rplaca +method doesn't exist, the +.code rplaca +function falls back on trying to store +.meta new-car-value +by means of the structure type's +.code lambda-set +method, using an index of zero. That is to say, if the type has no +.code rplaca +method, but does have a +.code lambda-set +method, then +.cblk +.meti << o . (lambda-set 0 << v) +.cble +is invoked. + .coNP Function @ from-list .synb .mets << object .[from-list << list ] |