2012-07-05

Lisp Syntax Readable?

lisp syntax is really unreadable. 10 years ago, i thought it's more of a joke for those uninitiated. But then surely the basic fact of uniformity is a problem for reading (because in nature, things are not uniform). But now having coded lisp for ≈5 years, i do find it comparatively unreadable.

here's sample code am currently reading.

(defun kill-new (string &optional replace yank-handler)
  "Make STRING the latest kill in the kill ring.
…"
  (if (> (length string) 0)
      (if yank-handler
          (put-text-property 0 (length string)
                             'yank-handler yank-handler string))
    (if yank-handler
        (signal 'args-out-of-range
                (list string "yank-handler specified for empty string"))))
  (unless (and kill-do-not-save-duplicates
               ;; Due to text properties such as 'yank-handler that
               ;; can alter the contents to yank, comparison using
               ;; `equal' is unsafe.
               (equal-including-properties string (car kill-ring)))
    (if (fboundp 'menu-bar-update-yank-menu)
        (menu-bar-update-yank-menu string (and replace (car kill-ring)))))
  (when save-interprogram-paste-before-kill
    (let ((interprogram-paste (and interprogram-paste-function
                                   (funcall interprogram-paste-function))))
      (when interprogram-paste
        (dolist (s (if (listp interprogram-paste)
                       (nreverse interprogram-paste)
                     (list interprogram-paste)))
          (unless (and kill-do-not-save-duplicates
                       (equal-including-properties s (car kill-ring)))
            (push s kill-ring))))))
  (unless (and kill-do-not-save-duplicates
               (equal-including-properties string (car kill-ring)))
    (if (and replace kill-ring)
        (setcar kill-ring string)
      (push string kill-ring)
      (if (> (length kill-ring) kill-ring-max)
          (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))))
  (setq kill-ring-yank-pointer kill-ring)
  (if interprogram-cut-function
      (funcall interprogram-cut-function string)))

Even though i hate Perl, but when perl script is well-coded, it's still more readable than lisp.

See also: The Concepts and Confusions of Prefix, Infix, Postfix and Fully Nested Notations.