From b7aae46f879bfc8a43781a08aaef9f506f7211bf Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 25 Jan 2012 23:40:40 -0800 Subject: * eval.c (dwim_loc): Handles full responsibility for assigning to list and array ranges. (op_modplace): Pass extra arguments to dwim_loc so it can do the job for ranges. If dwim_loc returns 0, it means that it did everything. (op_dwim): Support list and array ranges. * txr.1: Documented. --- txr.1 | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index dc6625e5..3853fe7f 100644 --- a/txr.1 +++ b/txr.1 @@ -4372,8 +4372,10 @@ shorthand for cons. That is to say, A .. B translates to (cons A B), and so for instance (a b .. (c d) e .. f . g) means (a (cons b (c d)) (cons e f) . g). -This is a syntactic sugar in certain situations in which a cons -is used to represent a pair of numbers or other objects. +This is a syntactic sugar useful in certain situations in which a cons is used +to represent a pair of numbers or other objects. For instance, if L +is a list, then [L 1 .. 3] computes a sublist of L consisting of +elements 1 through 2 (counting from zero). .SS The DWIM Brackets @@ -4843,10 +4845,22 @@ refers to the first element. Indexed list access does not throw exceptions. Negative indices yield nil, and indices beyond the end of a list yield nil. (However assignment to a nonexistent list element throws.) +.IP [ ..] +Retrieve the specified range of elements, exactly as if +using (sub-list ). +The range of elements is specified in the car and cdr fields of a cons cell, +for which the .. (dotdot) syntactic sugar is useful. + .IP [ ] Retrieve the specified element of a vector. This is equivalent to (vecref ). +.IP [ ..] +Retrieve the specified range of elements, exactly as if +using (sub-vec ). +The range of elements is specified in the car and cdr fields of a cons cell, +for which the .. (dotdot) syntactic sugar is useful. + .IP [ ] Retrieve the specified element of a string. This is equivalent to (chr-str ). @@ -4858,6 +4872,12 @@ or if there is no such entry. The list, vector and hash table forms of dwim denote places that can be assigned. +The list and vector range forms can be assigned only using the set operator, +not using the others like push and inc. Assigning to a vector range modifies +the vector object; it is implemented using replace-vec. Assigning to a list +range updates the form which contains the list, so the expression denoting the +list must be an assignable place. + .TP Notes: -- cgit v1.2.3