summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-06-30 21:42:48 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-06-30 21:42:48 -0700
commit349c01fff273ffcaf5d46873121a067eb82f7997 (patch)
treec4d69d70054d73a923512f1dfe9231c8f3ce9196 /txr.1
parentd7ea45f4c26ff460d062f24f3fbb33c018874dcf (diff)
downloadtxr-349c01fff273ffcaf5d46873121a067eb82f7997.tar.gz
txr-349c01fff273ffcaf5d46873121a067eb82f7997.tar.bz2
txr-349c01fff273ffcaf5d46873121a067eb82f7997.zip
Callable integers become assignable places.
* lib.c (dwim_set): Handle seq argument being an integer or range. * tests/012/callable.tl: A few tests. * txr.1: Documented.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.128
1 files changed, 27 insertions, 1 deletions
diff --git a/txr.1 b/txr.1
index c88e06a3..f2f4f975 100644
--- a/txr.1
+++ b/txr.1
@@ -14291,10 +14291,14 @@ defined by \*(TX programs.
.mets (gethash < hash < key <> [ alt ])
.mets (hash-userdata << hash )
.mets (dwim < obj-place < index <> [ alt ])
+.mets (dwim < integer < obj-place ) ;; integers are callable
+.mets (dwim < range < obj-place ) ;; ranges are callable
.mets (sub-list < obj >> [ from <> [ to ]])
.mets (sub-vec < obj >> [ from <> [ to ]])
.mets (sub-str < str >> [ from <> [ to ]])
.mets >> [ obj-place < index <> [ alt ]] ;; equivalent to dwim
+.mets >> [ integer < obj-place ]
+.mets >> [ range < obj-place ]
.mets (symbol-value << symbol-valued-form )
.mets (symbol-function << function-name-valued-form )
.mets (symbol-macro << symbol-valued-form )
@@ -15966,9 +15970,11 @@ retrieve a global macro expander using the function
.coNP Operator @ dwim
.synb
.mets (dwim << argument *)
-.mets <> '[' argument *']'
.mets (set (dwim < obj-place < index <> [ alt ]) << new-value )
+.mets (set (dwim >> { integer | << range } << obj-place ) << new-value )
+.mets <> '[' argument *']'
.mets (set >> '[' obj-place < index <> [ alt ]']' << new-value )
+.mets (set >> '[{' integer | << range } << obj-place']' << new-value )
.syne
.desc
The
@@ -16296,14 +16302,34 @@ These, in turn, rely on the specialized functions.
.code carray-sub
and
.codn carray-replace .
+
.meIP >> [ buf << index ]
Indexing is supported for objects of type
.codn buf .
This provides a way to access and store the individual bytes
of a buffer.
+
+.meIP >> [ integer << sequence ]
+If the left argument is an integer, it denotes selection of an
+element from
+.metn sequence .
+The
+.meta integer
+value acts as the index into a vector-like or list-like sequence,
+or a key into a hash table.
+
+.meIP >> [ range << sequence ]
+If the left argument is an range, it denotes selection of a
+subrange of
+.metn sequence .
.RE
.PP
+Note that the various above forms are not actually special cases of
+.code dwim
+but the consequence of the objects appearing as the first argument being
+callable as functions, and their respective semantics.
+
.TP* "Range Indexing:"
Vector and list range indexing is based from zero, meaning
that the first element is numbered zero, the second one