Steve Dekorte
05/13/2025, 4:31 PMKonrad Hinsen
05/14/2025, 6:11 AMMisha A
05/21/2025, 9:22 PMKonrad Hinsen
05/22/2025, 6:43 AMMisha A
05/22/2025, 11:03 AMKonrad Hinsen
05/22/2025, 11:26 AMTherefore each must roll their own text->ast convertor.Parsers for most languages are readily available. Python even has a Python parser in its standard library. It would be nice of course to make the AST even easier to access, but I don't see it as a major obstacle. The other points you list are partly an issue with text files, but mostly an issue with text representations of any kind. If you make ASTs the baseline representation of code, you still have to decide how to render it on screen, so code formatting matters exactly in the same way, just in a different place (the IDE rather than the text file).
Misha A
05/22/2025, 11:27 AMMisha A
05/22/2025, 11:31 AMso code formatting matters exactly in the same wayit would move it to client (= your IDE) where you could do all you want, write it however you want "tabs vs spaces" would never be a thing ever. linters would be compiler plugins alerting on semantics, not this "opening { must be on the new line, build failed" BS.
Misha A
05/22/2025, 11:36 AMKonrad Hinsen
05/22/2025, 3:47 PMMisha A
05/22/2025, 4:20 PMKonrad Hinsen
05/23/2025, 6:26 AMguitarvydas
05/23/2025, 12:22 PMTherefore each must roll their own text->ast convertor.Reality: existing tools want to deal with bracketed text. AST == Lisp
roll their own text->ast convertor.Overwhelming problem in 1960. Nothing-burger in 2025 (OhmJS, PEG, I'm fooling with text-to-text (t2t)).
Misha A
05/23/2025, 7:52 PMsemantic
in "AST (abstract syntax/semantic/etc tree)" for a reason.
"(foo bar baz)" tells you nothing about semantics.
foo
here might behave like or
– then both foo and bar must exist, but only one will be evaled,
or like def
– then foo is new sym, which might or might not shadow existing one, and baz must exist.
or like list
– then this is just list of whatever bar and baz eval to.
just having tokens conveniently grouped with parens is almost never enough.
re keeping, and building on top of: if you leave access to "lower level" format – there inevitably will be "out of band" changes and consequences.
And I'd argue that tabs-vs-spaces, formatter-wars, linters, package management, junky diffs, etc – are very much "today's problems" tooKonrad Hinsen
05/24/2025, 5:53 AMguitarvydas
05/25/2025, 2:48 AMguitarvydas
05/25/2025, 6:02 PMMisha A
06/02/2025, 2:20 PM(let [x 1] (+ x 1))
– (+ x 1)
sees x
from the previous vector, note that [x 1]
and (+ x 1)
are siblings, same level, yet one can see the other, but not vise versa. We (at least me) by default think of (+ x 1)
as "being inside of let, nested" but syntactic reality – expression dictating scope is sibling, not parent.
• control flow branches: which sexprs are sequential, and which are parallel: in (if foo bar baz)
bar and baz a parallel = "within single eval of this if - either bar or baz would be evaled but not both."
• "special" places, eg foo
after evaling (def foo 1)
is made available as global var (in clojure terminology); (let [x 1] )
- x is now local "var" available for anything "later" inside let
.
• maybe rendering hints (which is just one case of prev bullet-point, I guess), eg. in (cond pred1 foo pred666 bar)
- pred1
and pred666
are predicates, and foo
, bar
– are branches, and maybe I'd like for autoformatter to render those as 2 columns:
(cond
pred1 foo
pred666 bar)
but if first symbol is not cond, then it' would be just a list, where "items are interleaved columns" no longer applies, and maybe you want to pack-tile them, or render as a single column, or single row:
(kek pred1 foo pred666 bar)
(kek pred1 foo
pred666 bar)
(kek
pred1
foo
pred666
bar)
Misha A
06/02/2025, 2:25 PM|----*--*------------------------|
^ ^ ^ ^
line py lisp tree
Just because if you are:
- writing lisp in vim/emacs/ms code/idea/notepad as text (allows parse errors, like imbalanced parens)
- looking at diffs in terminal as git diff
output
- even if you are using paredit-like thingy which does not allow invalid trees, but it knows nothing about semantics I listed above (basically to syntax highlight you parse "tree" you just wrote with another thingy again)
- not to mention you can just open a file elsewhere and put unparsable junk there. I realize you can corrupt any file/format, but think of it as "another coworker edits your paredit-crafted-tree in notepad (usual situation, not a rare act of sabotage)" 🙂
– means you are writing lines of text = doing line oriented programmingMisha A
06/02/2025, 6:30 PM