Impossible wish: display( x <= y < z)
I think this is impossible, and I posted this before as a comment, but I want to post it here in case someone has a idea to make it happen.
With some of the proposal it is possible to write
display(x < y < z)
and it will interpreted as
(display (< x y z))
and the result is a boolean.
I'd like to be able to write
display(x < y <= z)
and also get a boolean as the result.
In Phyton you can write
phyton> print(x < y <= z)
but I suspect they are "cheating", i.e. the internal representation is different from the a naive transformation of the text. I think it is important to not add too many weird transformation be able to write macros without understanding all the details.
One possibility is to redefine < and <= as
(define (< x y) (and x y (old-< x y) y)
(define (<= x y) (and x y (old-<= x y) y)
so
display(x < y <= z)
is
(display (<= (< x y) z))
but the result is the number z instead of a boolean.
One solution is to write
display(x < y <= z && #t)
but the last && #t is not beginners friendly.
I agree that this is very desirable.
In Phyton you can write
phyton> print(x < y <= z)
but I suspect they are "cheating", i.e. the internal representation is different from the a naive transformation of the text. I think it is important to not add too many weird transformation be able to write macros without understanding all the details.
Reminded me of https://twitter.com/jangle/status/1227721188438421506
'c' in 'cat' == True
in Python expands to
('c' in 'cat') and ('cat' == True)
In Rebellion I defined compare-infix, which you can use like this:
(require rebellion/base/comparator)
(compare-infix real<=> 1 < 3 <= 5) ; returns #true