summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-07-07 07:00:14 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-07-07 07:00:14 -0700
commit52e1a059ea7feae38efb71330c83a671560e29fa (patch)
tree0c1f57afcdfb43a21870fad39690ddeb7b71a96b
parent10d16b5da0b45265d669f061db6f4457c4661811 (diff)
downloadtxr-52e1a059ea7feae38efb71330c83a671560e29fa.tar.gz
txr-52e1a059ea7feae38efb71330c83a671560e29fa.tar.bz2
txr-52e1a059ea7feae38efb71330c83a671560e29fa.zip
Lisp: lambda expressions are function names now.
* eval.c (lookup_fun): With this two-liner change, the forms ((lambda (x) x) 42) and (fun (lambda ())) just work. This is not just compatibility with other dialects; it is necessary for consistency with func-get-name, which already returns lambda expressions, effectively asserting that they are function names. * txr.1: Fix documentation for fun operator. The Dialect Note saying that a lambda expression is not a function name in TXR Lisp is removed. Document that function names may be any of those produced by func-get-name. This has already been true for macros and methods, just not for lambda expressions. Under fun-get-name, document that lambda expressions are produced for interpreted functions not found in any binding by the previous searches.
-rw-r--r--eval.c2
-rw-r--r--txr.131
2 files changed, 25 insertions, 8 deletions
diff --git a/eval.c b/eval.c
index f8186977..e2759186 100644
--- a/eval.c
+++ b/eval.c
@@ -490,6 +490,8 @@ val lookup_fun(val env, val sym)
cons(sym, static_slot(type, slot)));
} else if (car(sym) == macro_s) {
return lookup_mac(nil, cadr(sym));
+ } else if (car(sym) == lambda_s) {
+ return cons(sym, func_interp(env, sym));
}
}
return or2(gethash(top_fb, sym),
diff --git a/txr.1 b/txr.1
index 11b1ece9..d2f88b71 100644
--- a/txr.1
+++ b/txr.1
@@ -13544,22 +13544,26 @@ function in the current lexical environment.
The
.meta function-name
-is a symbol denoting a named function: a built in
+may be a symbol denoting a named function: a built in
function, or one defined by
.codn defun .
+The
+.meta function-name
+may also take any of the forms specified in the description of the
+.code func-get-name
+function. If such a
+.meta function-name
+refers to a function which exists, then the
+.code fun
+operator yields that function.
+
Note: the
.code fun
operator does not see macro bindings. It is possible to
retrieve a global macro expander using the function
.codn symbol-macro .
-.TP* "Dialect Note:"
-A lambda expression is not a function name in \*(TL. The
-syntax
-.code "(fun (lambda ...))"
-is invalid.
-
.coNP Operator @ dwim
.synb
.mets (dwim << argument *)
@@ -16278,7 +16282,18 @@ is a symbol denoting the struct type and
is the static slot of the struct type which holds
.metn func .
-If all the searches fail, then
+If
+.meta func
+is an interpreted function not found under any name,
+then a lambda expression denoting that function
+is returned in the syntax
+.cblk
+.meti (lambda < args << form *)
+.cble
+
+If
+.meta func
+cannot be identified as a function, then
.code nil
is returned.