2 ms·
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 C
by praptak 4y ago
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.
- kazinator 4y agoCommon 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)))