[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash ca36c57 239/316: Allow -lambda with no arguments
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dash ca36c57 239/316: Allow -lambda with no arguments |
Date: |
Mon, 15 Feb 2021 15:58:09 -0500 (EST) |
branch: externals/dash
commit ca36c573a4c099f5b7d8589c07c567561339fe51
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>
Allow -lambda with no arguments
* dash.el (-lambda): Allow empty arglist. Fix error data signaled.
* dev/examples.el (-lambda): Add tests for this.
* README.md:
* dash.texi: Regenerate docs.
---
README.md | 4 ++--
dash.el | 23 ++++++++++++-----------
dash.texi | 4 ++--
dev/examples.el | 5 ++++-
4 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/README.md b/README.md
index e4b262b..b59a5fd 100644
--- a/README.md
+++ b/README.md
@@ -2616,10 +2616,10 @@ such that:
(-lambda (x y ...) body)
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.
-See [`-let`](#-let-varlist-rest-body) for the description of destructuring
mechanism.
+See [`-let`](#-let-varlist-rest-body) for a description of the destructuring
mechanism.
```el
(-map (-lambda ((x y)) (+ x y)) '((1 2) (3 4) (5 6))) ;; => '(3 7 11)
diff --git a/dash.el b/dash.el
index 6903b42..052a9b0 100644
--- a/dash.el
+++ b/dash.el
@@ -2294,27 +2294,28 @@ such that:
(-lambda (x y ...) body)
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.
-See `-let' for the description of destructuring mechanism."
+See `-let' for a description of the destructuring mechanism."
(declare (doc-string 2) (indent defun)
(debug (&define sexp
[&optional stringp]
[&optional ("interactive" interactive)]
def-body)))
(cond
- ((not (consp match-form))
- (signal 'wrong-type-argument "match-form must be a list"))
- ;; no destructuring, so just return regular lambda to make things faster
- ((-all? 'symbolp match-form)
+ ((nlistp match-form)
+ (signal 'wrong-type-argument (list #'listp match-form)))
+ ;; No destructuring, so just return regular `lambda' for speed.
+ ((-all? #'symbolp match-form)
`(lambda ,match-form ,@body))
- (t
- (let* ((inputs (--map-indexed (list it (make-symbol (format "input%d"
it-index))) match-form)))
- ;; TODO: because inputs to the lambda are evaluated only once,
- ;; -let* need not to create the extra bindings to ensure that.
+ ((let ((inputs (--map-indexed
+ (list it (make-symbol (format "input%d" it-index)))
+ match-form)))
+ ;; 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.
- `(lambda ,(--map (cadr it) inputs)
+ `(lambda ,(mapcar #'cadr inputs)
(-let* ,inputs ,@body))))))
(defmacro -setq (&rest forms)
diff --git a/dash.texi b/dash.texi
index 1ec69fb..2547c89 100644
--- a/dash.texi
+++ b/dash.texi
@@ -3950,10 +3950,10 @@ such that:
(-lambda (x y @dots{}) body)
has the usual semantics of @code{lambda}. Furthermore, these get
-translated into normal lambda, so there is no performance
+translated into normal @code{lambda}, so there is no performance
penalty.
-See @code{-let} (@pxref{-let}) for the description of destructuring mechanism.
+See @code{-let} (@pxref{-let}) for a description of the destructuring
mechanism.
@example
@group
diff --git a/dev/examples.el b/dev/examples.el
index 4dbc38c..d8ba79a 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -1416,7 +1416,10 @@ value rather than consuming a list to produce a single
value."
(funcall (-lambda ((a) (b)) (+ a b)) '(1 2 3) '(4 5 6)) => 5
(-lambda a t) !!> wrong-type-argument
(funcall (-lambda (a b) (+ a b)) 1 2) => 3
- (funcall (-lambda (a (b c)) (+ a b c)) 1 (list 2 3)) => 6)
+ (funcall (-lambda (a (b c)) (+ a b c)) 1 (list 2 3)) => 6
+ (funcall (-lambda () 1)) => 1
+ (let* ((x 0) (f (-lambda () (setq x (1+ x))))) (--dotimes 3 (funcall f)) x)
+ => 3)
(defexamples -setq
(progn (-setq a 1) a) => 1
- [elpa] externals/dash 1d58249 212/316: Write -iterate in terms of --iterate, (continued)
- [elpa] externals/dash 1d58249 212/316: Write -iterate in terms of --iterate, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 47f8b2b 214/316: Clean up -doto, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 794bf8c 219/316: ; Fix omission in last change, ELPA Syncer, 2021/02/15
- [elpa] externals/dash f9d67ae 223/316: Merge pull request #314 from blc/reductions, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 31a655b 224/316: Fix -cons* with no arguments, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 3423be4 227/316: Merge pull request #364 from blc/info-look, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 558cd95 230/316: Fix take/drop splits (again), ELPA Syncer, 2021/02/15
- [elpa] externals/dash f975634 233/316: Merge pull request #235, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 8248997 234/316: Merge pull request #207 from holomorph/iota, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 3694ae9 236/316: * dash.el (-iota): Simplify and purify., ELPA Syncer, 2021/02/15
- [elpa] externals/dash ca36c57 239/316: Allow -lambda with no arguments,
ELPA Syncer <=
- [elpa] externals/dash bf8a462 243/316: Partially revert last change, ELPA Syncer, 2021/02/15
- [elpa] externals/dash d7d0acb 242/316: Don't call eval, ELPA Syncer, 2021/02/15
- [elpa] externals/dash bf8d876 238/316: Merge pull request #363 from blc/list, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 76ace7f 240/316: Fix error signaling, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 1ccf08d 244/316: ; Fix last change, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 2625bc5 247/316: Don't use insert-file-contents-literally, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 7583e65 248/316: Revert --map to using mapcar, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 6f5888c 251/316: Extend --filter and --remove docs and tests, ELPA Syncer, 2021/02/15
- [elpa] externals/dash db45ee7 252/316: Optimize -remove-first a bit, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 0e5acda 260/316: Simplify -non-nil, ELPA Syncer, 2021/02/15