summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-02-02 02:37:17 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-02-02 02:37:17 -0800
commit256ba9369ab15b1eced9aa81fd1e466e138e2933 (patch)
treec579e25cf5e1cd302755c486c66f742eef853099 /txr.1
parent97b07f495505f5e3b9b0e99e8d024d85eedf0952 (diff)
downloadtxr-256ba9369ab15b1eced9aa81fd1e466e138e2933.tar.gz
txr-256ba9369ab15b1eced9aa81fd1e466e138e2933.tar.bz2
txr-256ba9369ab15b1eced9aa81fd1e466e138e2933.zip
* eval.c (apply): Support string and vector arglist.
(do_eval_args): Support string or vector in dot position. * lib.c (tolist): New function. * lib.h (tolist): Declared. * txr.1: Document how apply and dot position in compound forms supports strings as well as vectors.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.124
1 files changed, 16 insertions, 8 deletions
diff --git a/txr.1 b/txr.1
index 33f9d267..e2e4a383 100644
--- a/txr.1
+++ b/txr.1
@@ -5022,10 +5022,11 @@ If the form is a function call then the arguments are evaluated. If any of the
arugments are symbols, they are treated according to Lisp-2 namespacing rules.
Additionally, if there is an expression in the dotted position, it is also
-evaluated. It should evaluate to a list or vector. The elements of the list
-or vector generate additional arguments for the function call.
-In some other Lisp dialects, a function called apply (or similar) must be
-used to do the same thing.
+evaluated. It should evaluate to a sequence: a list, vector or string. The
+elements of the sequence generate additional arguments for the function
+call. In some other Lisp dialects, a function called apply (or similar) must
+be used to do the same thing, and applying sequences other than lists is not
+supported.
The DWIM brackets are similar, except that the first position is an arbitrary
expression which is evaluated according to the same rules as the remaining
@@ -5041,9 +5042,11 @@ Examples:
;; a contains 3
;; b contains 4
;; c contains #(5 6 7)
+ ;; s contains "xyz"
(foo a b . c) ;; calls (foo 3 4 5 6 7)
(foo a) ;; calls (foo 3)
+ (foo . s) ;; calls (foo #\ex #\ey #\ez)
[foo a b . c] ;; calls (foo 3 4 5 6 7)
@@ -7130,14 +7133,16 @@ can be expressed as:
.TP
Syntax:
- (apply <function> <arglist>)
+ (apply <function> <argsequence>)
.TP
Description:
-The apply function converts a list of values <arglist> into individual arguments
-which are passed to <function>. The return value of the apply invocation is
-that of <function>.
+The apply function converts a sequence of values <argsequence> into individual
+arguments which are passed to <function>. The return value of the apply
+invocation is that of <function>.
+
+<argsequence> must be list, vector or string.
.TP
Examples:
@@ -7145,6 +7150,9 @@ Examples:
;; '(1 2 3) becomes arguments to list, thus (list 1 2 3).
(apply (fun list) '(1 2 3)) -> (1 2 3)
+ ;; "abc" is separated into characters which become arguments of list
+ (apply (fun list) "abc") -> (#\ea #\eb #\ec)
+
.TP
Dialect Note 1: