|
|
|
@ -2294,27 +2294,28 @@ such that: |
|
|
|
(-lambda (x y ...) body) |
|
|
|
(-lambda (x y ...) body) |
|
|
|
|
|
|
|
|
|
|
|
has the usual semantics of `lambda'. Furthermore, these get |
|
|
|
has the usual semantics of `lambda'. Furthermore, these get |
|
|
|
translated into normal lambda, so there is no performance |
|
|
|
translated into normal `lambda', so there is no performance |
|
|
|
penalty. |
|
|
|
penalty. |
|
|
|
|
|
|
|
|
|
|
|
See `-let' for the description of destructuring mechanism." |
|
|
|
See `-let' for a description of the destructuring mechanism." |
|
|
|
(declare (doc-string 2) (indent defun) |
|
|
|
(declare (doc-string 2) (indent defun) |
|
|
|
(debug (&define sexp |
|
|
|
(debug (&define sexp |
|
|
|
[&optional stringp] |
|
|
|
[&optional stringp] |
|
|
|
[&optional ("interactive" interactive)] |
|
|
|
[&optional ("interactive" interactive)] |
|
|
|
def-body))) |
|
|
|
def-body))) |
|
|
|
(cond |
|
|
|
(cond |
|
|
|
((not (consp match-form)) |
|
|
|
((nlistp match-form) |
|
|
|
(signal 'wrong-type-argument "match-form must be a list")) |
|
|
|
(signal 'wrong-type-argument (list #'listp match-form))) |
|
|
|
;; no destructuring, so just return regular lambda to make things faster |
|
|
|
;; No destructuring, so just return regular `lambda' for speed. |
|
|
|
((-all? 'symbolp match-form) |
|
|
|
((-all? #'symbolp match-form) |
|
|
|
`(lambda ,match-form ,@body)) |
|
|
|
`(lambda ,match-form ,@body)) |
|
|
|
(t |
|
|
|
((let ((inputs (--map-indexed |
|
|
|
(let* ((inputs (--map-indexed (list it (make-symbol (format "input%d" it-index))) match-form))) |
|
|
|
(list it (make-symbol (format "input%d" it-index))) |
|
|
|
;; TODO: because inputs to the lambda are evaluated only once, |
|
|
|
match-form))) |
|
|
|
;; -let* need not to create the extra bindings to ensure that. |
|
|
|
;; TODO: because inputs to the `lambda' are evaluated only once, |
|
|
|
|
|
|
|
;; `-let*' need not create the extra bindings to ensure that. |
|
|
|
;; We should find a way to optimize that. Not critical however. |
|
|
|
;; We should find a way to optimize that. Not critical however. |
|
|
|
`(lambda ,(--map (cadr it) inputs) |
|
|
|
`(lambda ,(mapcar #'cadr inputs) |
|
|
|
(-let* ,inputs ,@body)))))) |
|
|
|
(-let* ,inputs ,@body)))))) |
|
|
|
|
|
|
|
|
|
|
|
(defmacro -setq (&rest forms) |
|
|
|
(defmacro -setq (&rest forms) |
|
|
|
|