[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash bf8d876 238/316: Merge pull request #363 from blc/
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dash bf8d876 238/316: Merge pull request #363 from blc/list |
Date: |
Mon, 15 Feb 2021 15:58:08 -0500 (EST) |
branch: externals/dash
commit bf8d8767f6a10d90ccfd256633d2743676f1e3a8
Merge: 3694ae9 1152feb
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>
Merge pull request #363 from blc/list
---
README.md | 17 +++++++++++------
dash.el | 18 ++++++++++++------
dash.texi | 17 +++++++++++------
dev/examples.el | 9 +++++++--
4 files changed, 41 insertions(+), 20 deletions(-)
diff --git a/README.md b/README.md
index 74d8c55..e4b262b 100644
--- a/README.md
+++ b/README.md
@@ -291,7 +291,7 @@ Other list functions not fit to be classified elsewhere.
* [-last-item](#-last-item-list) `(list)`
* [-butlast](#-butlast-list) `(list)`
* [-sort](#-sort-comparator-list) `(comparator list)`
-* [-list](#-list-rest-args) `(&rest args)`
+* [-list](#-list-optional-arg-rest-args) `(&optional arg &rest args)`
* [-fix](#-fix-fn-list) `(fn list)`
### Tree operations
@@ -2094,15 +2094,20 @@ if the first element should sort before the second.
(--sort (< it other) '(3 1 2)) ;; => '(1 2 3)
```
-#### -list `(&rest args)`
+#### -list `(&optional arg &rest args)`
-Return a list based on `args`.
-If the first item of `args` is already a list, simply return it.
-Otherwise, return a list with `args` as elements.
+Ensure `arg` is a list.
+If `arg` is already a list, return it as is (not a copy).
+Otherwise, return a new list with `arg` as its only element.
+
+Another supported calling convention is (-list &rest `args`).
+In this case, if `arg` is not a list, a new list with all of
+`args` as elements is returned. This use is supported for
+backward compatibility and is otherwise deprecated.
```el
(-list 1) ;; => '(1)
-(-list 1 2 3) ;; => '(1 2 3)
+(-list nil) ;; => nil
(-list '(1 2 3)) ;; => '(1 2 3)
```
diff --git a/dash.el b/dash.el
index b12588c..6903b42 100644
--- a/dash.el
+++ b/dash.el
@@ -2618,12 +2618,18 @@ if the first element should sort before the second."
(declare (debug (form form)))
`(-sort (lambda (it other) ,form) ,list))
-(defun -list (&rest args)
- "Return a list based on ARGS.
-If the first item of ARGS is already a list, simply return it.
-Otherwise, return a list with ARGS as elements."
- (declare (pure t) (side-effect-free t))
- (if (listp (car args)) (car args) args))
+(defun -list (&optional arg &rest args)
+ "Ensure ARG is a list.
+If ARG is already a list, return it as is (not a copy).
+Otherwise, return a new list with ARG as its only element.
+
+Another supported calling convention is (-list &rest ARGS).
+In this case, if ARG is not a list, a new list with all of
+ARGS as elements is returned. This use is supported for
+backward compatibility and is otherwise deprecated."
+ (declare (advertised-calling-convention (arg) "2.18.0")
+ (pure t) (side-effect-free t))
+ (if (listp arg) arg (cons arg args)))
(defun -repeat (n x)
"Return a new list of length N with each element being X.
diff --git a/dash.texi b/dash.texi
index ee38333..1ec69fb 100644
--- a/dash.texi
+++ b/dash.texi
@@ -3202,10 +3202,15 @@ if the first element should sort before the second.
@end defun
@anchor{-list}
-@defun -list (&rest args)
-Return a list based on @var{args}.
-If the first item of @var{args} is already a list, simply return it.
-Otherwise, return a list with @var{args} as elements.
+@defun -list (&optional arg &rest args)
+Ensure @var{arg} is a list.
+If @var{arg} is already a list, return it as is (not a copy).
+Otherwise, return a new list with @var{arg} as its only element.
+
+Another supported calling convention is (-list &rest @var{args}).
+In this case, if @var{arg} is not a list, a new list with all of
+@var{args} as elements is returned. This use is supported for
+backward compatibility and is otherwise deprecated.
@example
@group
@@ -3213,8 +3218,8 @@ Otherwise, return a list with @var{args} as elements.
@result{} '(1)
@end group
@group
-(-list 1 2 3)
- @result{} '(1 2 3)
+(-list nil)
+ @result{} nil
@end group
@group
(-list '(1 2 3))
diff --git a/dev/examples.el b/dev/examples.el
index 2ab60a7..4dbc38c 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -1009,12 +1009,17 @@ value rather than consuming a list to produce a single
value."
(defexamples -list
(-list 1) => '(1)
- (-list 1 2 3) => '(1 2 3)
+ (-list ()) => ()
(-list '(1 2 3)) => '(1 2 3)
+ (-list 1 2 3) => '(1 2 3)
+ (let ((l (list 1 2))) (setcar (-list l) 3) l) => '(3 2)
+ (let ((l (list 1 2))) (setcar (apply #'-list l) 3) l) => '(1 2)
(-list '((1) (2))) => '((1) (2))
(-list) => ()
- (-list ()) => ()
(-list () 1) => ()
+ (-list () ()) => ()
+ (-list 1 ()) => '(1 ())
+ (-list 1 '(2)) => '(1 (2))
(-list '(())) => '(())
(-list '(() 1)) => '(() 1))
- [elpa] externals/dash f9d67ae 223/316: Merge pull request #314 from blc/reductions, (continued)
- [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, 2021/02/15
- [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 <=
- [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
- [elpa] externals/dash 9ad0d2b 266/316: Extend -map-indexed docs and tests, ELPA Syncer, 2021/02/15
- [elpa] externals/dash f61769d 256/316: * dash.el (dash--keywords): Prefer rx., ELPA Syncer, 2021/02/15
- [elpa] externals/dash 2aeb4e4 264/316: Use actual advertised function signature in README, ELPA Syncer, 2021/02/15