4 ms·
Lisp programmer here. Traditional S-expressions, by their definition, ignore most of whitespace; additionally, reading sexprs is always a linear operation with
by phoe-krk 1y ago
Lisp programmer here.
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.
- tgv 1y agoA normal tree would be easier to read eq mul pow a a a 2
- derriz 1y agoTurned 90, maybe? eq: mul: a a pow: a 2
- tgv 1y agoThat's the classical LISP way of doing it: (eq (mul a a) (pow a 2)) or (eq (mul a a ) (pow a 2 ) )
- hyperhello 1y agox*x == pow(x,2)
- derriz 1y agoWe have a winner! Actually, I'd suggest a slight improvement: x*x = x^2
- xigoi 1y agox · x = x²
- TacticalCoder 1y ago(== (* x x) (pow x 2))
- amno 1y ago(= * x x ^ x 2)
- unrealhoang 1y agono yaml programming please :(
- uncircle 1y agoFrom the YAML inventor himself: https://yamlscript.org/ https://yamlscript.org/ The length people go to avoid Lisp, only to reinvent it, badly.
- unstruktured 1y agoThanks for restoring my sanity. Was quite confused of the value added by the author.
- velcrovan 1y agoIt gets worse/better. Since Racket allows you to hook your own reader in front of (or in place of) the default reader, you can have things like 2D syntax: #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 https://docs.racket-lang.org/2d/index.html
- perrygeo 1y agoThat's amazing and terrible at the same time. I love it.
- phoe-krk 1y agoTruth be told, you can intercept the reader in Common Lisp, too, and here it actually makes some sense since the 2D value is immediately visually grokkable as an ASCII-art table. The proposed 2D sexpr notation does not have this.
- f1shy 1y agoYes that part must be a joke! 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.
- tearflake 1y agoHere is another example, an axiom from propositional logic: (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.
- exeldapp 1y agoNot sure if that example helps. You can make any programming language hard to read without some basic formatting. The way I would write the sexpr would be: (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.
- tearflake 1y agoThat looks clean, can't argue that.