by whartung · 2mo ago · 0 comments
Consider:
(defun split-line (line)
(remove-if #'(lambda (word) (string= word ""))
(split-sequence:split-sequence #\Space line)))
Now imagine if we had some "lower weight" glyph besides the paren. .defun split-line .line,
.remove-if #'.lambda .word, .string= word "",,
.split-sequence:split-sequence #\Space line,,,
Obviously a contrived example replacing () with ., but you can see how "heavy" the parens and how they can dominate what the eye sees.With experience, the parens vanish. The parens being large and common take control of the conversation more than they should.
(split-sequence:split-sequence #\Space line)
now imagine if that was (split-string " " line)
image if the whole function was (defun split (line)
(remove [\(word) (= "" word)] [split-string " " line]))
or even (defun split (line)
(remove "" [split-string " " line]))
*using [] in place of rainbow parens for clarity of sub argumentsWhat remains is field access. Curiously, first-edition K&R C actually required similar type-encoding in field names because field names were global:
https://usenet.trashworldnews.com/?thread=288637
Same for ML, which is roughly of the same age, except that it took much longer for ML-derived languages to lift this restriction.
On the other hand, every time I wrote down examples that I think should look really bad in prefix notation, like this one:
p3.x := (p1.x + p2.x) / 2;
It is actually not so terrible with a sufficiently streamlined prefix syntax: (setf x p3 (/ (+ (. x p1) (. x p2)) 2))
But maybe there should be a mechanism that the reader transforms p1.x to (. x p1), in the same way that it transforms 's into (quote s). Then we get this: (setf x p3 (/ (+ p1.x p2.x 2)))
Or if there is a concept of a place: (set p3.x (/ (+ p1.x p2.x 2)))
But that probably needs static typing for an efficient implementation (or set needs to deconstruct its first argument during compilation). (split-sequence:split-sequence #\Space line)
Why would you do that? You could just use `uiop:split-string` and import the function symbol into your current namespace so you can call it as `split-string`. (split-string "a b c")Although my general stance remains, most lisp code bases I've seen are remarkably verbose which leads to a glazing over far more than the lack of distinct symbols or prefix notation
But when your function ends with ))))))))) -- that is the issue. Too much shit is being shoved into one method. But this is not the fault of lisp, it's the fault of the programmer who is wielding it.