summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisplib.c2
-rw-r--r--share/txr/stdlib/ffi.tl3
-rw-r--r--txr.19
3 files changed, 12 insertions, 2 deletions
diff --git a/lisplib.c b/lisplib.c
index 2b57c578..3e57d627 100644
--- a/lisplib.c
+++ b/lisplib.c
@@ -526,7 +526,7 @@ static val ffi_set_entries(val dlt, val fun)
lit("with-dyn-lib"), lit("deffi"), lit("deffi-type"), lit("deffi-cb"),
lit("deffi-var"), lit("typedef"), lit("sizeof"), lit("alignof"),
lit("offsetof"), lit("arraysize"), lit("elemsize"), lit("elemtype"),
- lit("ffi"), lit("carray-ref"),
+ lit("ffi"), lit("carray-ref"), lit("carray-sub"),
nil
};
set_dlt_entries(dlt, name, fun);
diff --git a/share/txr/stdlib/ffi.tl b/share/txr/stdlib/ffi.tl
index da29c1e5..a041692f 100644
--- a/share/txr/stdlib/ffi.tl
+++ b/share/txr/stdlib/ffi.tl
@@ -133,3 +133,6 @@
^(ffi-type-compile ',type))
(define-accessor carray-ref carray-refset)
+
+(define-place-macro carray-sub (carray : (from 0) (to t))
+ ^(sub ,carray ,from ,to))
diff --git a/txr.1 b/txr.1
index 4aa99e06..451b219c 100644
--- a/txr.1
+++ b/txr.1
@@ -56928,9 +56928,10 @@ then the expected string conversion semantics applies.
Both of these functions return
.metn carray .
-.coNP Function @ carray-sub
+.coNP Accessor @ carray-sub
.synb
.mets (carray-sub < carray >> [ from <> [ to ]])
+.mets (set (carray-sub < carray >> [ from <> [ to ]]) << new-val )
.syne
.desc
The
@@ -56965,6 +56966,12 @@ can be severed by invoking
on the returned object, after which the two no longer share storage,
and modifications in the original are not reflected in the subrange.
+If
+.code carray-sub
+is used as a syntactic place, behaves exactly like the
+.code sub
+accessor, via a place macro substitution to that form.
+
.coNP Function @ carray-replace
.synb
.mets (carray-replace < carray < item-sequence >> [ from <> [ to ]])