diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-09-27 08:06:47 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-09-27 08:06:47 -0700 |
commit | 70dca98f3500158716f49d5281d55769a44f7f67 (patch) | |
tree | a635c43c7710ec946e480f5fc287461c25f035f4 /share | |
parent | 38868195bfc5df39c11e85df4e1550c197f32009 (diff) | |
download | txr-70dca98f3500158716f49d5281d55769a44f7f67.tar.gz txr-70dca98f3500158716f49d5281d55769a44f7f67.tar.bz2 txr-70dca98f3500158716f49d5281d55769a44f7f67.zip |
symbol-function: support lambda expressions.
* eval.c (lookup_fun): Check for a lambda expression and
return a faked binding containing the interpreted function.
(do_eval, op_fun): Remove checks for lambda that are now
being done in lookup_fun. In many other places where
lookup_fun is used, we still need lambda checks, like
in the expander.
* share/txr/stdlib/place.tl (sys:get-fun-getter-setter): Take
form argument. Diagnose assignments to lambda, and to unknown
function place syntax.
(defplace symbol-function): Pass sys:*pl-form* to
sys:get-fun-getter-setter as form argument.
* txr.1: fboundp and symbol-function doc updated.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/place.tl | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/share/txr/stdlib/place.tl b/share/txr/stdlib/place.tl index 0aef499a..9fa15bdc 100644 --- a/share/txr/stdlib/place.tl +++ b/share/txr/stdlib/place.tl @@ -776,7 +776,7 @@ ^(fmakunbound ',',sym))) ,body))) -(defun sys:get-fun-getter-setter (sym) +(defun sys:get-fun-getter-setter (f sym) (tree-case sym ((type struct slot) (if (eq type 'meth) @@ -795,6 +795,10 @@ (cons (op cdr) (op sys:rplacd cell))) :)) + ((op . rest) + (if (eq op 'lambda) + (compile-error f "cannot assign to lambda") + (compile-error f "invalid function syntax ~s" sym))) (else (let ((cell (or (gethash sys:top-fb sym) (sethash sys:top-fb sym (cons sym nil))))) @@ -804,7 +808,7 @@ (defplace (symbol-function sym-expr) body (getter setter (with-gensyms (gs-sym) - ^(let ((,gs-sym (sys:get-fun-getter-setter ,sym-expr))) + ^(let ((,gs-sym (sys:get-fun-getter-setter ',sys:*pl-form* ,sym-expr))) (macrolet ((,getter () ^(call (car ,',gs-sym))) (,setter (val) ^(call (cdr ,',gs-sym) ,val))) ,body)))) |