On 2024-01-02, Lawrence D'Oliveiro <
[email protected]d> wrote:
I’m not a fan of the “parenthesis pileup” tradition of LISP code layout.
Well, you came to the right language. Odds are high that you will be
working alone in Lisp (not called LISP for a few decades now, by the
way).
So you will never run into a situation in which you're asked
to produce normal looking code ending in ))))) pringles.
(Unless you do something silly, like contribute a patch to someone
else's existing project.)
Having used a number of different programming languages over
the years, I have evolved a common set layout conventions that has
worked reasonably well across them. So for example, when parentheses
in LISP represent something resembling statement blocks, I like to put
the openers and closers at the same indentation level, which means
putting the closer on a line by itself. This, accompanied by a comment indicating the type of construct being closed, I think helps a lot
with readability. Elisp example:
(defun convert-to-region-codes (beg end)
"converts alphabetic characters in the selection to “region indicator symbols”."
(interactive "*r")
(unless (use-region-p)
(ding)
(keyboard-quit)
) ; unless
(let
(
deactivate-mark
(intext (delete-and-extract-region beg end))
c
)
(dotimes (i (- end beg))
(setq c (elt intext i))
(cond
((and (>= c ?A) (<= c ?Z))
(setq c (+ (- c ?A) #x1F1E6))
)
((and (>= c ?a) (<= c ?z))
(setq c (+ (- c ?a) #x1F1E6))
)
) ; cond
(insert-char c)
) ; dotimes
) ; let
) ; convert-to-region-codes
You forgot a few, for instance:
((and (>= c
l?A) ;; >=
(<= c
?Z) ;; <=
) ;; and
(setq c
(+ (- c
?A
) ;; -
#x1F1E6
) ;; +
) ;; setq
) ;; cond pair
You go show `em how it oughtta be formatted!
--
TXR Programming Language:
http://nongnu.org/txr
Cygnal: Cygwin Native Application Library:
http://kylheku.com/cygnal
Mastodon: @
[email protected]
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)