diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-04-05 07:34:01 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-04-05 07:34:01 -0700 |
commit | cd0ff844f0edf0f9dbee49bf84e6c497a02d8e33 (patch) | |
tree | 851bb748761e12f66fd7896e6d1d401d3160544a /txr.1 | |
parent | fe7851a39ab718bba5d68c66f0d723fcb0ddec55 (diff) | |
download | txr-cd0ff844f0edf0f9dbee49bf84e6c497a02d8e33.tar.gz txr-cd0ff844f0edf0f9dbee49bf84e6c497a02d8e33.tar.bz2 txr-cd0ff844f0edf0f9dbee49bf84e6c497a02d8e33.zip |
doc: document null-safe method call.
* txr.1: The notation obj.?(fun ...) exists, but is not
documented. Let's fix that.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 30 |
1 files changed, 26 insertions, 4 deletions
@@ -11470,16 +11470,21 @@ to produce .codn "(qref a b c)" . If the referencing dot is immediately followed by a question mark, it forms -a single token, which produces the following syntactic variation: +a single token, which produces the following syntactic variation, +in which the following item is annotated as a list headed by +the symbol +.codn t : .verb a.?b <--> (t a).b <--> (qref (t a) b) a.?b.?c <--> (t a).(t b).c <--> (qref (t a) (t b) c) + a.?(b) <--> (t a).(b) <--> (qref (t a) (b)) + (a).?b <--> (t (a)).b <--> (qref (t (a)) b) .brev This syntax denotes .I null-safe -access to structure slots. +access to structure slots and methods. .code a.?b means that .code a @@ -11492,7 +11497,24 @@ otherwise, must evaluate to a .code struct which has a slot -.codn b . +.codn b , +and the expression denotes access to that slot. +Similarly, +.code "a.?(b 1)" +means that if +.code a +evaluates to +.codn nil , +the expression yields +.codn nil ; +otherwise, +.code a +is treated as a struct object whose method +.code b +is invoked with argument +.codn 1 , +and the value returned by that method becomes the value of +the expression. Integer tokens cannot be involved in this syntax, because they form floating-point constants when juxtaposed with a dot. @@ -11534,7 +11556,7 @@ is as follows: .verb .?a <--> (uref t a) .?a.b <--> (uref t a b) - .?a.?b <--> (uref t a (t b)) + .?a.?b <--> (uref t a (t b)) .brev When the unbound referencing dot is applied to a dotted expression, |