diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-06-16 06:40:49 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-06-16 06:40:49 -0700 |
commit | d212fc6284a6b7858da4570ef4d22cb88eec747a (patch) | |
tree | ce7c6d4eb2b2bb51ba8138d5a2ae0a64653d5738 /lib.c | |
parent | 39317da1ce84bb30b103fc580219cb4e509da281 (diff) | |
download | txr-d212fc6284a6b7858da4570ef4d22cb88eec747a.tar.gz txr-d212fc6284a6b7858da4570ef4d22cb88eec747a.tar.bz2 txr-d212fc6284a6b7858da4570ef4d22cb88eec747a.zip |
Support ref, refset on structs via lambda, lambda-set.
* lib.c (ref, refset): Check for lambda and lambda-set,
respectively, and use it.
* txr.1: Documented.
* tests/012/aseq.tl (add lambda): Fix previously unused
broken method which now causes test to go into infinite
recursion.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -9246,6 +9246,11 @@ val ref(val seq, val ind) return gethash(seq, ind); if (seq->co.cls == carray_s) return carray_ref(seq, ind); + if (structp(seq)) { + val lambda_meth = maybe_slot(seq, lambda_s); + if (lambda_meth) + return funcall2(lambda_meth, seq, ind); + } /* fallthrough */ case CONS: case LCONS: @@ -9283,6 +9288,12 @@ val refset(val seq, val ind, val newval) return sethash(seq, ind, newval); if (seq->co.cls == carray_s) return carray_refset(seq, ind, newval); + if (structp(seq)) { + val lambda_set_meth = maybe_slot(seq, lambda_set_s); + if (lambda_set_meth) + return funcall3(lambda_set_meth, seq, ind, newval); + } + /* fallthrough */ default: type_mismatch(lit("ref: ~s is not a sequence"), seq, nao); } |