(defmacro ifx (:env env . body)
(let ((*expand-hook* (fun infix-expand-hook)))
(expand ^(progn ,*body) env)))
On 2025-03-31, Kaz Kylheku <643-408-1753@kylheku.com> wrote:
(defmacro ifx (:env env . body)
(let ((*expand-hook* (fun infix-expand-hook)))
(expand ^(progn ,*body) env)))
Doh! I just though of expander-let which can do this nicely.
(ifx (let ((i 0))(while (i ++ < 9)
1> (parse-infix '(sin a + b + c + d))
(sin (+ (+ (+ a b) c)
d))
But, if we put parentheses on the operand of sin, then it's no longer
the unary sin, but a function call with that argument:
2> (parse-infix '(sin (a) + b + c + d))
(+ (+ (+ (sin a) b)
c)
d)
I think it is already better than SRFI-105 curly braces and some
other systems.
1> (parse-infix '(sin a + b + c + d))
(sin (+ (+ (+ a b) c)
d))
But, if we put parentheses on the operand of sin, then it's no longer
the unary sin, but a function call with that argument:
2> (parse-infix '(sin (a) + b + c + d))
(+ (+ (+ (sin a) b)
c)
d)
For someone coming from "statically typed functional programming", this
is *very* weird.
All those languages (Haskell/OCaml/SML/Coq/Idris/Agda/...) treat
(sin a + b + c + d)
the same as
(sin (a) + b + c + d)
Ah, but how about higher precedence operators?
Would you want
sin a * b * c
to be
sin (a) * b *c
It seems that a useful behavior to have would be for the
range of the unary operator to stop when we encounter
another such unary operator; i.e.
sin a + b + c + sin d + e + f
^ ^
Ah, but how about higher precedence operators?
Same: the "usual" convention in those languages (and in most ++-calculus papers) is that function application takes the shape "e1 e2" and binds tighter than "anything else".
Would you want
sin a * b * c
to be
sin (a) * b *c
Yup.
It seems that a useful behavior to have would be for the
range of the unary operator to stop when we encounter
another such unary operator; i.e.
sin a + b + c + sin d + e + f
^ ^
Well, now you're falling into the world of heuristics to try and handle
the inconsistent mix of rules used by various authors.
You're obviously free to go there, but don't count me in.
sin a + b + c + sin d + e + fWell, now you're falling into the world of heuristics to try and handle
the inconsistent mix of rules used by various authors.
You're obviously free to go there, but don't count me in.
Stefan Monnier <monnier@iro.umontreal.ca> wrote or quoted:
sin a + b + c + sin d + e + fWell, now you're falling into the world of heuristics to try and handle
the inconsistent mix of rules used by various authors.
You're obviously free to go there, but don't count me in.
Languages such as "AsciiMath" or "AsciiMathML" have been created
to deal with such notations, and there is software available to
convert them to LaTeX or MathML.
In one case, a double space was made significant, to resolve
some ambiguities as in "sin a/2", in which the "/" now binds
stronger than the sin, different from "sin a/2".
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 65 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 08:16:37 |
| Calls: | 862 |
| Files: | 1,311 |
| D/L today: |
2 files (6,679K bytes) |
| Messages: | 264,942 |