5 ms·
Lispers have been using structural editing since at least the 80s. Structural editing essentially allows modification to Lisp programs to be made as edits to a
by reikonomusha 4y ago
Lispers have been using structural editing since at least the 80s. Structural editing essentially allows modification to Lisp programs to be made as edits to a data structure with tokens. It sounds radical but it's really quite simple, at least in a language like Lisp, where
(setf x 5)
is a piece of code that is truly and immediately represented by a data structure (a list containing the symbol SETF, the symbol X, and the number 5).
Let's do a routine example. In your editor, how would you get from
(f x (y|)) z
to
(f x y| z)
if the '|' was your cursor? Maybe you think you should click around and delete the right parentheses, and carefully balance them. With structural editing, a Lisp programmer might first do a "splice":
(f x (y|)) z
;; splice: press Alt+s
(f x y|) z
and then they will do a "slurp" (slang for moving the next thing after the cursor into the current enclosing parentheses):
(f x y|) z
;; slurp: press Control-<right>
(f x y| z)
We've managed to get to our destination by using only two structural commands that makes a parenthesis-mismatch error fundamentally impossible.
These are examples written with a package called "Paredit" in mind, and it actually makes editing Lisp a distinct joy compared to character-based editing of other languages. Some Lisp programmers prefer slightly different styles of structural editing, but they all reduce to the same motivations: Edit a Lisp program's structure, not its characters.
So, contrary to popular belief, Lisp programmers do not count parentheses. Lisp programmers' eyes do not glaze over at the sight of Lisp. Syntax errors are probably a <1% occurrence out of all of the errors one encounters. Though purely informally empirical, I'd be willing to get that syntax errors are far less common in Lisp compared to syntax-rich languages like C++, Haskell, etc.
People who dabble with Lisp for 15 minutes in notepad.exe invariably run into syntax errors, but that is not a reflection of what serious hobbyists and professional Lisp programmers do.
- Joel_Mckay 4y agoWhile I appreciate a parenthesis laden straw man argument, this just reinforces the assertion about poor readability. Have a great day =)
- reikonomusha 4y agoSorry, I made a mistake. You said Lisp has a readability issue which I interpreted a statement of generality, but I think you meant Lisp is difficult for me to read which I have no business arguing against, except to offer you guidance on what I believe are best practices for reading and writing Lisp. (In short, it's to use an editor specifically equipped to write Lisp. It gives you canonical indentation and structural editing. Emacs is the most popular choice, but there are extensions to Vim and VSCode; as well as full-blown commercial IDEs (plural!) by LispWorks and Franz Inc.)
- Joel_Mckay 4y agoagain, getting sidetracked by making things personal. You would not be upset, unless deep down you also agree this was true. https://www.youtube.com/watch?v=q225u-qGpas https://www.youtube.com/watch?v=q225u-qGpas
- corinroyal 4y agoWhen you are reduced to arguing that your opponent's passion proves your point, you know you have lost.
- Joel_Mckay 4y agoI would be interested in hearing how degenerative prefix notation affecting visual acuity relates to a cults indignation. Having someones opinions disrespected under the guise of a off-topic counter-argument, doesn't sound much like a prize. Here is an up-vote, and have a wonderful day. =)
- joeman1000 4y agoToxic kindness and skill issues right here.
- Joel_Mckay 4y agoYou do realize that Julia code parsing and code-lowering were implemented in FemtoLisp a.k.a. a Scheme/Lisp dialect And I genuinely still like you, even if you think the world is a terrible place. =)
- joeman1000 4y agoOf course. I love both Julia and lisps. How does your comment contradict anything I’ve said?
- Joel_Mckay 4y agoHard to say really, as I do not like to encourage off topic personal nonsense. Have a wonderful day =)