summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--stdlib/infix.tl17
-rw-r--r--txr.128
2 files changed, 24 insertions, 21 deletions
diff --git a/stdlib/infix.tl b/stdlib/infix.tl
index f455a755..4fd343a1 100644
--- a/stdlib/infix.tl
+++ b/stdlib/infix.tl
@@ -219,24 +219,27 @@
(infix-error oexp "nodestack extra entries ~s" nodestack))
(first nodestack)))
+(defmacro funp (env sym)
+ ^(or (fboundp ,sym) (lexical-fun-p ,env ,sym)))
+
(defun-match detect-infix
- (((@x @y . @rest))
+ (((@x @y . @rest) @env)
(let* ((xu [ifx-uops x])
(yu [ifx-uops y])
(yo [ifx-ops y])
(yb (if-match [. @toks] y
(or (and (consp toks)
(null (cdr toks)))
- (detect-infix toks))))
- (ya (and (not yu) (not yo) (not (fboundp y))))
- (xa (and (not xu) (not (fboundp x)))))
+ (detect-infix toks env))))
+ (ya (and (not yu) (not yo) (not (funp env y))))
+ (xa (and (not xu) (not (funp env x)))))
(or
(and xa (or yo yb))
(and xu ya (neq xu.sym xu.lispsym))
(if-match (@z . @nil) rest
(let* ((zu [ifx-uops z])
(zo [ifx-ops z])
- (za (and (not zu) (not zo) (not (fboundp z)))))
+ (za (and (not zu) (not zo) (not (funp env z)))))
(or
(and xu yu (or zu za))
(and xu ya zo))))))))
@@ -245,7 +248,7 @@
(ignore env)
(cond
((eq type-sym :macro) exp)
- ((and (meq type-sym :fun nil) (detect-infix exp))
+ ((and (meq type-sym :fun nil) (detect-infix exp env))
(parse-infix exp))
((match-case exp
([] exp)
@@ -262,7 +265,7 @@
(boundp tok)))
tok)
(@(require (@x @y . @rest)
- (and (not (fboundp x)) (fboundp y)))
+ (and (not (funp env x)) (funp env y)))
(let ((rexp (infix-expand-hook rest env nil)))
(if (eq rexp rest)
^(,y ,x ,*rest)
diff --git a/txr.1 b/txr.1
index fc991584..f4180651 100644
--- a/txr.1
+++ b/txr.1
@@ -54216,10 +54216,12 @@ denotes a prefix (unary) operator; the letter
.code o
denotes an infix operator and the letter
.code A
-denotes an argument which is not the name of a function or operator.
+denotes an argument which is not the name of a global function, lexical
+function in the current macro environment, or operator.
Additionally, the letter
.code u*
-indicates a prefix operator which is not also the name of a function.
+indicates a prefix operator which is not also the name of a global or
+lexical function.
The patterns which indicate a form for processing via
.code parse-infix
are:
@@ -54237,15 +54239,15 @@ ordinary expression
.code "(...)"
with the same content. If this converted expression in indicated as infix,
then the parent expression is indicates as infix, otherwise not.
-.coIP (u u u ...)
+.coIP "(u u u ...)"
Three consecutive leading prefix operators.
-.coIP (u u A ...)
+.coIP "(u u A ...)"
Two consecutive leading prefix operators followed by an argument.
-.coIP (u A o ...)
+.coIP "(u A o ...)"
A prefix operator followed by an argument, followed by an infix
operator.
-.coIP (u* A ...)
-A prefix operator which is not also the name of a function,
+.coIP "(!f A ...)"
+A prefix operator which is not also the name of a global or lexical function,
followed by an argument.
.RE
@@ -54397,13 +54399,11 @@ into
.codn "(+ i 1)" .
A form not falling into any of the above rules is recognized as "phony infix"
-if: it consists of at least two elements, the first element is not not an
-object satisfying the
-.code fboundp
-function, but the second element
-.B is
-an object satisfying that function. When a form is thus recognized,
-it is transformed by exchanging the first and second position.
+if: it consists of at least two elements, where the first element is not
+a function, and the second element is a function. Both the lexical and
+global function namespaces are considered.
+When a form is thus recognized,
+it is transformed by exchanging the first and second positions.
Furthermore, if there are additional arguments after these two positions, they are
taken as an independent expression which is passed through the infix expansion
hook. If it is transformed by the hook, then the transformed expression