Sujet : Re: Integral types and own type definitions (was Re: Suggested method for returning a string from a C program?)
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 31. Mar 2025, 22:14:57
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250331140525.470@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-03-31, Kaz Kylheku <
643-408-1753@kylheku.com> wrote:
On 2025-03-31, Alan Mackenzie <acm@muc.de> wrote:
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>
[ .... ]
>
I don't know of any language that uses "-" for both negation (prefix,
one operand) and subtraction (infix, two operands) and treats -5
as a single token rather than a unary minus operator applied to the
constant/literal "5".
>
How about Lisp? The unary operator is (- 5), the binary (- 10 5).
>
It doesn't match your second parenthetical remark ("infix") but
otherwise it does.
>
Lisp could be infix if we want with some macro:
>
(infix-environment
... (10 - (a * 3)) ...)
I had been toying with the idea in my mind for a while, and this gave me the
impetus to get it working. It's very simple if you extend the Lisp dialect with
a suitable code walking hook.
Working, advanced proof of concept:
$ ./txr -i infix.tl
TXR's no-spray organic production means every bug is carefully removed by hand.
1> (ifx (let ((a 1) (b 2) (c 3))
((a + b) * 3)))
9
I'm going to post about this in more detail in comp.lang.lisp, where
it is topical.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca