Hacker News new | ask | show | jobs
by jimbokun 1384 days ago
Clojure takes this criticism to heart, and at least uses different delimiters for indicate different kinds of syntactic structures. Like () for classic lists, [] for arrays, {} for maps. Helps with visually detecting different kinds of structures in your code.
1 comments

Clojure also prunes the excessive parentheses whenever the structure is obvious from context. E.g. "(let ((a 1) (b 2)) ...)" becomes "(let [a 1 b 2] ...)" and Clojure just requires an even number of elements so that the pairing can be inferred.
Common Lisp has this in the `setq` and `psetq` macros. E.g. exchange `x` and `y`:

  (psetq x y y x)
You can easily have a nesting reduced binding macro, like (var (x 1 y 1) (list x y)), with sequential binding.

Untested:

  (defmacro var (pairs &body body)
    (if (oddp (length pairs))
      (error "~s: variables and init-forms must occur pairwise" 'var))
    `(let* ,(loop for (var init) on pairs by #'cddr
                  unless (and var (symbolp var)
                              (not (eql var t))
                              (not (keywordp var)))
                  do
                    (error "~s: ~s isn't a variable name" 'var var)
                  collect (list var init))
       ,@body)))