summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-05-15 07:41:19 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-05-15 07:41:19 -0700
commitc606261b92348ef7b0f934705ee46ee4ccf28bab (patch)
tree384d5448080b423bf4ff72b455eb368176f74edb /txr.1
parenta500d048021a018800ed28f23509800f6b45bf6f (diff)
downloadtxr-c606261b92348ef7b0f934705ee46ee4ccf28bab.tar.gz
txr-c606261b92348ef7b0f934705ee46ee4ccf28bab.tar.bz2
txr-c606261b92348ef7b0f934705ee46ee4ccf28bab.zip
New special operator: progv
Adding a progv operator, similar to the Common Lisp one. * eval.c (progv_s): New symbol variable. (op_progv): New static function. (do_expand): Recognize and traverse the progv form. (rt_progv): New static function: run-time support for compiled progv. (eval_init): Initialize progv_s, and register the the op_progv operator interpreting function. * stdlib/compilert (compiler compile): Handle progv operator ... (compiler comp-progv): ... via this new method. * tests/019/progv.tl: New file. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.162
1 files changed, 62 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index f0558d16..539c95b2 100644
--- a/txr.1
+++ b/txr.1
@@ -15060,6 +15060,68 @@ closures, but are captured in delimited continuations.
(let (:a nil)) -> error, :a and nil can't be used as variables
.brev
+.coNP Operator @ progv
+.synb
+.mets (progv < symbols-expr < values-expr << body-form *)
+.syne
+.desc
+The
+.code progv
+operator binds dynamic variables, and evaluates the
+.metn body-form s
+in the dynamic scope of those bindings. The bindings are removed
+when the form terminates. The result value is that of the
+last
+.meta body-form
+or else
+.code nil
+if there are no forms.
+
+The
+.meta symbols-expr
+and
+.meta values-expr
+are expressions which are evaluated. Their values are expected
+to be lists, of bindable symbols and arbitrary values, respectively.
+The symbols coming from one list are bound to the values coming
+from the other list.
+
+If there are more symbols than values, then the extra symbols
+will appear unbound, as if they were first bound and then hidden
+using the
+.code makunbound
+function.
+
+If there are more values than symbols, the extra values are ignored.
+
+Note that dynamic binding takes place for the symbols even if they
+have not been introduced as special variables via
+.code defvar
+or
+.codn defparm .
+However, if those symbols appear as expressions denoting variables inside the
+.metn body-form s,
+they will not necessarily be treated as dynamic variables.
+If they have lexical definitions in scope, those will be referenced.
+Furthermore, the compiler treats undefined variables as global
+references, and not dynamic.
+
+.TP* Examples:
+
+.verb
+
+ (progv '(a b) '(1 2) (cons a b)) -> (1 . 2)
+
+ (progv '(x) '(1) (let ((x 4)) (symbol-value 'x))) -> 1
+
+ (let ((x 'lexical)
+ (vars (list 'x))
+ (vals (list 'dynamic)))
+ (progv vars vals (list x (symbol-value 'x))))
+
+ --> (lexical dynamic)
+.brev
+
.SS* Functions
.coNP Operator @ defun
.synb