3 ms·
Is structural editing a genuine advantage over line-based editing? The author presents it as such, but their structural editing example shows that it takes thr
by modernerd 6y ago
Is structural editing a genuine advantage over line-based editing?
The author presents it as such, but their structural editing example shows that it takes three operations to negate a condition (create array, write “not”, slurp forwards).
That would be one operation in most line-based languages (write “!”), and it also introduces less line noise.
- vrnvu 6y agoIn a simple example like the author provided maybe is not that obvious but try to imagine an example with a more complex nested syntax and maybe some threading or function composition in it. If you have to modify the behaviour of a specific block of code you only need to edit that structure and your block won't get messy neither requiere special syntax. As you say, If your "!" transaltes to an expression in your language and you are already writting pure functions that compose niceley then I agree that the benefit would be at a syntax level only, the homogeneity of treating all code (macros or runtime) equally.
- zozbot234 6y ago> Is structural editing a genuine advantage over line-based editing? A full-featured editor should support both. Line editing is convenient for some editing operations/workflows where you don't necessarily have a well-formed AST at all times. But for many other workflows, structural editing is preferable.
- chriswarbo 6y agoStructural editing can be used in many languages, not just Lispy ones (although it's most powerful in Lispy languages). I use Emacs to write Haskell, Scala, Python, Bash, etc. and use at least some structural editing operations all the time, e.g. ctrl-right turns '(a, b), c' into '(a, b, c)' and ctrl-left goes the other way.