Thanks for restoring my sanity. Was quite confused of the value added by the author.
Here, I brought down the enthusiasm a bit in the closing word. I hope it creates less confusion now.
(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.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.
(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.
It might even be easier to treat the input string as a 2D grid than as a sequence and have a parsing head that behaves like a 2x2 convolutional kernel...
This would make for either a great Advent of Code, or a nightmare interview question, I love it.
Blocks are parsed in the following way: when we get the beginning count of block opening characters, we move Y by one, loop right while whitespace, until we encounter ending count of block characters.
In transposed block, we just switch X and Y, it is easily done with pointers, and use the same code.