by phoe-krk · 1y ago · 0 comments
Traditional S-expressions, by their definition, ignore most of whitespace; additionally, reading sexprs is always a linear operation without the need to backtrack by more than one character.
The suggestion from this post violates both assumptions by introducing a 2D structure to code. To quote this post's examples, it requires the multiline string in
(fst-atom """ trd-atom)
00001
00002
00003
"""
to be fully read before TRD-ATOM. It also forces the reading function to jump up and down vertically in order to read the structure in * ( )
* e ( ) ( )
* q m ( ) p ( ) *
u a a o a 2 *
l w *
The author also states that (eq (mul (a a)) (pow (a 2)))
is less readable than * ( )
* *eq* ( ) ( )
* *mul* ( ) *pow* ( ) *
*a* *a* *a* *2* *
*
Then there's the ending passage:> we hope that the introduced complexity is justified by the data readability expressed this way.
I cannot force myself to read this post as anything but a very poor Befungesque joke.
#lang 2d racket
(require 2d/match)
(define (subtype? a b)
#2dmatch
╔══════════╦══════════╦═══════╦══════════╗
║ a b ║ 'Integer ║ 'Real ║ 'Complex ║
╠══════════╬══════════╩═══════╩══════════╣
║ 'Integer ║ #t ║
╠══════════╬══════════╗ ║
║ 'Real ║ ║ ║
╠══════════╣ ╚═══════╗ ║
║ 'Complex ║ #f ║ ║
╚══════════╩══════════════════╩══════════╝)
https://docs.racket-lang.org/2d/index.html eq
mul pow
a a a 2 eq:
mul:
a
a
pow:
a
2 (eq (mul a
a)
(pow a
2))
or (eq
(mul
a
a
)
(pow
a
2
)
)Actually, I'd suggest a slight improvement: x*x = x^2
The length people go to avoid Lisp, only to reinvent it, badly.
I’ve seen dozens of attempts to make S-Exp “better” even the original M-Exp. I also did some experiments myself. But at the end, I come back to goo’ol s-exp. Seems to be a maximum (or minimum) found just perchance.
(impl (impl p (impl q r)) (impl (impl p q) (impl p r)))
which, vertically indented in a transposed block, looks like this: * ( )
* i ( ) ( )
* m i p ( ) i ( ) ( )
p m i q r m i p q i p r
l p m p m m *
l p l p p *
l l l *
which, using transposed lines within the transposed block, finally looks like this: * ( )
* *impl* ( ) ( ) *
* *impl* *p* ( ) *impl* ( ) ( ) *
*impl* *q* *r* *impl* *p* *q* *impl* *p* *r* *
This time I won't make any judgements. Could be good, could be bad, you decide. (impl
(impl
p
(impl q r))
(impl
(impl p q)
(impl p r)))
It's clear when each section begins and ends and doesn't require complex parsing rules.