GNU bug report logs -
#16963
A patch to create a list-with-tail primitive.
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 16963 in the body.
You can then email your comments to 16963 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16963
; Package
emacs
.
(Fri, 07 Mar 2014 16:48:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Demetrios Obenour <demetriobenour <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 07 Mar 2014 16:48:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Since a comment in backquote.el said that backquote-list* needed to be a
primitive, here is an implementation of it as one, under the name
list-with-tail.
=== modified file 'src/alloc.c'
--- src/alloc.c 2014-02-28 21:45:34 +0000
+++ src/alloc.c 2014-03-07 13:27:33 +0000
@@ -2593,6 +2593,26 @@
return val;
}
+DEFUN ("list-with-tail", Flist_with_tail, Slist_with_tail, 0, MANY, 0,
+ doc: /* Return a newly created list with specified arguments as
elements,
+except for the last argument, which becomes the tail of the list.
+At least one argument is required.
+usage: (list &rest OBJECTS &last TAIL) */)
+ (ptrdiff_t nargs, Lisp_Object *args)
+{
+ if (nargs == 0)
+ error ("Wrong number of arguments");
+ register Lisp_Object val;
+ nargs--;
+ val = args[nargs];
+
+ while (nargs > 0)
+ {
+ nargs--;
+ val = Fcons (args[nargs], val);
+ }
+ return val;
+}
DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
doc: /* Return a newly created list of length LENGTH, with each
element being INIT. */)
@@ -6921,6 +6941,7 @@
defsubr (&Scons);
defsubr (&Slist);
+ defsubr (&Slist_with_tail);
defsubr (&Svector);
defsubr (&Smake_byte_code);
defsubr (&Smake_list);
Change Log:
This creates a built-in function, list-with-tail,
that is identical to backquote-list*-function
in backquote.el except that it is a primitive.
This follows the suggestion made in a backquote.el
Sincerely,
Demetrios Obenour
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16963
; Package
emacs
.
(Tue, 25 Mar 2014 02:11:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 16963 <at> debbugs.gnu.org (full text, mbox):
> Since a comment in backquote.el said that backquote-list* needed to be a
> primitive, here is an implementation of it as one, under the name
> list-with-tail.
I think it would make more sense to call it `list*'. Also it might make
sense to change backquote.el so it uses this `list*' (tho probably only
when passed with enough arguments).
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16963
; Package
emacs
.
(Tue, 25 Mar 2014 02:46:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 16963 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 03/24/2014 07:10 PM, Stefan wrote:
>> Since a comment in backquote.el said that backquote-list* needed to be a
>> primitive, here is an implementation of it as one, under the name
>> list-with-tail.
>
> I think it would make more sense to call it `list*'. Also it might make
> sense to change backquote.el so it uses this `list*' (tho probably only
> when passed with enough arguments).
Agreed. On more that one occasion, I've wished we had a CL-less `list*'.
If you do add this feature, please make sure the existing list* compiler
macros keep working.
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16963
; Package
emacs
.
(Thu, 27 Mar 2014 23:38:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 16963 <at> debbugs.gnu.org (full text, mbox):
On Mon, 2014-03-24 at 19:45 -0700, Daniel Colascione wrote:
> On 03/24/2014 07:10 PM, Stefan wrote:
> >> Since a comment in backquote.el said that backquote-list* needed to be a
> >> primitive, here is an implementation of it as one, under the name
> >> list-with-tail.
> >
> > I think it would make more sense to call it `list*'. Also it might make
> > sense to change backquote.el so it uses this `list*' (tho probably only
> > when passed with enough arguments).
>
> Agreed. On more that one occasion, I've wished we had a CL-less `list*'.
> If you do add this feature, please make sure the existing list* compiler
> macros keep working.
>
What about just deleting these compiler macros, and making cl-list* an
alias for list*?
There seems to be little point in keeping them if list* is a primitive.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16963
; Package
emacs
.
(Thu, 27 Mar 2014 23:39:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 16963 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 03/27/2014 04:37 PM, Demetrios Obenour wrote:
> On Mon, 2014-03-24 at 19:45 -0700, Daniel Colascione wrote:
>> On 03/24/2014 07:10 PM, Stefan wrote:
>>>> Since a comment in backquote.el said that backquote-list* needed to be a
>>>> primitive, here is an implementation of it as one, under the name
>>>> list-with-tail.
>>>
>>> I think it would make more sense to call it `list*'. Also it might make
>>> sense to change backquote.el so it uses this `list*' (tho probably only
>>> when passed with enough arguments).
>>
>> Agreed. On more that one occasion, I've wished we had a CL-less `list*'.
>> If you do add this feature, please make sure the existing list* compiler
>> macros keep working.
>>
> What about just deleting these compiler macros, and making cl-list* an
> alias for list*?
>
> There seems to be little point in keeping them if list* is a primitive.
The new list* doesn't have an opcode, but cons does.
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16963
; Package
emacs
.
(Fri, 28 Mar 2014 00:44:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 16963 <at> debbugs.gnu.org (full text, mbox):
On Thu, 2014-03-27 at 16:38 -0700, Daniel Colascione wrote:
> On 03/27/2014 04:37 PM, Demetrios Obenour wrote:
> > On Mon, 2014-03-24 at 19:45 -0700, Daniel Colascione wrote:
> >> On 03/24/2014 07:10 PM, Stefan wrote:
> >>>> Since a comment in backquote.el said that backquote-list* needed to be a
> >>>> primitive, here is an implementation of it as one, under the name
> >>>> list-with-tail.
> >>>
> >>> I think it would make more sense to call it `list*'. Also it might make
> >>> sense to change backquote.el so it uses this `list*' (tho probably only
> >>> when passed with enough arguments).
> >>
> >> Agreed. On more that one occasion, I've wished we had a CL-less `list*'.
> >> If you do add this feature, please make sure the existing list* compiler
> >> macros keep working.
> >>
> > What about just deleting these compiler macros, and making cl-list* an
> > alias for list*?
> >
> > There seems to be little point in keeping them if list* is a primitive.
>
> The new list* doesn't have an opcode, but cons does.
>
Ah I see -- there might be a speed advantage in repeated cons calls, up
to a point. At what point would the function look-up be slower than
repeated function calls (I thought that function calls in Emacs Lisp are
slow)?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16963
; Package
emacs
.
(Sat, 29 Mar 2014 01:48:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 16963 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Thu, 2014-03-27 at 16:38 -0700, Daniel Colascione wrote:
> On 03/27/2014 04:37 PM, Demetrios Obenour wrote:
> > On Mon, 2014-03-24 at 19:45 -0700, Daniel Colascione wrote:
> >> On 03/24/2014 07:10 PM, Stefan wrote:
> >>>> Since a comment in backquote.el said that backquote-list* needed to be a
> >>>> primitive, here is an implementation of it as one, under the name
> >>>> list-with-tail.
> >>>
> >>> I think it would make more sense to call it `list*'. Also it might make
> >>> sense to change backquote.el so it uses this `list*' (tho probably only
> >>> when passed with enough arguments).
> >>
> >> Agreed. On more that one occasion, I've wished we had a CL-less `list*'.
> >> If you do add this feature, please make sure the existing list* compiler
> >> macros keep working.
> >>
> > What about just deleting these compiler macros, and making cl-list* an
> > alias for list*?
> >
> > There seems to be little point in keeping them if list* is a primitive.
>
> The new list* doesn't have an opcode, but cons does.
>
Good point! My testing showed four nested cons calls to be much faster
than list* with five arguments by several dozen times.
Maybe list* should be a macro instead?
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16963
; Package
emacs
.
(Sat, 29 Mar 2014 01:49:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 16963 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 03/28/2014 06:46 PM, Demetrios Obenour wrote:
> On Thu, 2014-03-27 at 16:38 -0700, Daniel Colascione wrote:
>> On 03/27/2014 04:37 PM, Demetrios Obenour wrote:
>> > On Mon, 2014-03-24 at 19:45 -0700, Daniel Colascione wrote:
>> >> On 03/24/2014 07:10 PM, Stefan wrote:
>> >>>> Since a comment in backquote.el said that backquote-list* needed to be a
>> >>>> primitive, here is an implementation of it as one, under the name
>> >>>> list-with-tail.
>> >>>
>> >>> I think it would make more sense to call it `list*'. Also it might make
>> >>> sense to change backquote.el so it uses this `list*' (tho probably only
>> >>> when passed with enough arguments).
>> >>
>> >> Agreed. On more that one occasion, I've wished we had a CL-less `list*'.
>> >> If you do add this feature, please make sure the existing list* compiler
>> >> macros keep working.
>> >>
>> > What about just deleting these compiler macros, and making cl-list* an
>> > alias for list*?
>> >
>> > There seems to be little point in keeping them if list* is a primitive.
>>
>> The new list* doesn't have an opcode, but cons does.
>>
> Good point! My testing showed four nested cons calls to be much faster
> than list* with five arguments by several dozen times.
>
> Maybe list* should be a macro instead?
No, list* as a function is perfectly fine --- we might want to call it
indirectly sometimes, e.g., with apply. The compiler macro is sufficient
to convert it to cons calls when we know it's safe. M-x disassemble is
your friend. :-)
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16963
; Package
emacs
.
(Sat, 29 Mar 2014 13:32:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 16963 <at> debbugs.gnu.org (full text, mbox):
On Fri, 2014-03-28 at 18:48 -0700, Daniel Colascione wrote:
> On 03/28/2014 06:46 PM, Demetrios Obenour wrote:
> > On Thu, 2014-03-27 at 16:38 -0700, Daniel Colascione wrote:
> >> On 03/27/2014 04:37 PM, Demetrios Obenour wrote:
> >> > On Mon, 2014-03-24 at 19:45 -0700, Daniel Colascione wrote:
> >> >> On 03/24/2014 07:10 PM, Stefan wrote:
> >> >>>> Since a comment in backquote.el said that backquote-list* needed to be a
> >> >>>> primitive, here is an implementation of it as one, under the name
> >> >>>> list-with-tail.
> >> >>>
> >> >>> I think it would make more sense to call it `list*'. Also it might make
> >> >>> sense to change backquote.el so it uses this `list*' (tho probably only
> >> >>> when passed with enough arguments).
> >> >>
> >> >> Agreed. On more that one occasion, I've wished we had a CL-less `list*'.
> >> >> If you do add this feature, please make sure the existing list* compiler
> >> >> macros keep working.
> >> >>
> >> > What about just deleting these compiler macros, and making cl-list* an
> >> > alias for list*?
> >> >
> >> > There seems to be little point in keeping them if list* is a primitive.
> >>
> >> The new list* doesn't have an opcode, but cons does.
> >>
> > Good point! My testing showed four nested cons calls to be much faster
> > than list* with five arguments by several dozen times.
> >
> > Maybe list* should be a macro instead?
>
> No, list* as a function is perfectly fine --- we might want to call it
> indirectly sometimes, e.g., with apply. The compiler macro is sufficient
> to convert it to cons calls when we know it's safe. M-x disassemble is
> your friend. :-)
>
Ah thanks!
Here is a patch to fix the Lisp files to exploit a list* primitive.
=== modified file 'lisp/emacs-lisp/cl-lib.el'
--- lisp/emacs-lisp/cl-lib.el 2014-01-01 07:43:34 +0000
+++ lisp/emacs-lisp/cl-lib.el 2014-03-29 13:12:10 +0000
@@ -527,19 +527,13 @@
;; (while (consp (cdr x)) (pop x))
;; x))
-(defun cl-list* (arg &rest rest)
+(defalias 'cl-list* (symbol-function 'list*)
"Return a new list with specified ARGs as elements, consed to last
ARG.
Thus, `(cl-list* A B C D)' is equivalent to `(nconc (list A B C) D)',
or to
`(cons A (cons B (cons C D)))'.
-\n(fn ARG...)"
- (declare (compiler-macro cl--compiler-macro-list*))
- (cond ((not rest) arg)
- ((not (cdr rest)) (cons arg (car rest)))
- (t (let* ((n (length rest))
- (copy (copy-sequence rest))
- (last (nthcdr (- n 2) copy)))
- (setcdr last (car (cdr last)))
- (cons arg copy)))))
+\n(fn ARG...)")
+(put 'list* 'compiler-macro #'cl--compiler-macro-list*)
+(put 'cl-list* 'compiler-macro #'cl--compiler-macro-list*)
(defun cl-ldiff (list sublist)
"Return a copy of LIST with the tail SUBLIST removed."
=== modified file 'lisp/emacs-lisp/cl.el'
--- lisp/emacs-lisp/cl.el 2014-01-01 07:43:34 +0000
+++ lisp/emacs-lisp/cl.el 2014-03-29 12:58:27 +0000
@@ -257,7 +257,6 @@
adjoin
copy-list
ldiff
- list*
cddddr
cdddar
cddadr
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16963
; Package
emacs
.
(Wed, 24 Feb 2016 02:53:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 16963 <at> debbugs.gnu.org (full text, mbox):
Demetrios Obenour <demetriobenour <at> gmail.com> writes:
> Since a comment in backquote.el said that backquote-list* needed to be a
> primitive, here is an implementation of it as one, under the name
> list-with-tail.
[...]
> -(defun cl-list* (arg &rest rest)
> +(defalias 'cl-list* (symbol-function 'list*)
> "Return a new list with specified ARGs as elements, consed to last
Reading this bug report, there seemed to be general agreement that Emacs
should have `list*', and that `cl-list*' should be an alias for it, but
these patches were not applied.
I can't find your name in the Emacs copyright assignment file -- would
you be willing to sign a copyright assignment to the FSF?
And then, could you re-spin the patches, along with changes to the
lispref manual as needed (and an etc/NEWS entry)?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16963
; Package
emacs
.
(Wed, 26 Jun 2019 14:31:01 GMT)
Full text and
rfc822 format available.
Message #35 received at 16963 <at> debbugs.gnu.org (full text, mbox):
Lars Ingebrigtsen <larsi <at> gnus.org> writes:
> Reading this bug report, there seemed to be general agreement that Emacs
> should have `list*', and that `cl-list*' should be an alias for it, but
> these patches were not applied.
>
> I can't find your name in the Emacs copyright assignment file -- would
> you be willing to sign a copyright assignment to the FSF?
I asked that three years ago, when the patch was already two years old,
so I'm guessing that this is not going to happen, so I'm closing this
bug report.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug closed, send any further explanations to
16963 <at> debbugs.gnu.org and Demetrios Obenour <demetriobenour <at> gmail.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Wed, 26 Jun 2019 14:31:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16963
; Package
emacs
.
(Fri, 28 Jun 2019 03:15:01 GMT)
Full text and
rfc822 format available.
Message #40 received at 16963 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:
> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>
>> Reading this bug report, there seemed to be general agreement that Emacs
>> should have `list*', and that `cl-list*' should be an alias for it, but
>> these patches were not applied.
>>
>> I can't find your name in the Emacs copyright assignment file -- would
>> you be willing to sign a copyright assignment to the FSF?
>
> I asked that three years ago, when the patch was already two years old,
> so I'm guessing that this is not going to happen, so I'm closing this
> bug report.
Oh, this reminds me I had started writing a patch for this. I used the
name cons* instead of list* though, I always found it more logical:
cons* is cons repeated, just like let* is let repeated. Let me dust it
off:
[0001-Implement-cons-as-a-C-subroutine-Bug-16963.patch (text/plain, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16963
; Package
emacs
.
(Fri, 28 Jun 2019 03:31:02 GMT)
Full text and
rfc822 format available.
Message #43 received at 16963 <at> debbugs.gnu.org (full text, mbox):
> Oh, this reminds me I had started writing a patch for this. I used the
> name cons* instead of list* though, I always found it more logical:
> cons* is cons repeated, just like let* is let repeated. Let me dust it
> off:
The name has long been `list*' in Lisp, including
in Common Lisp. That's the name that should (still)
be used, IMO.
http://clhs.lisp.se/Body/f_list_.htm
list* is like list except that the last argument to list
becomes the car of the last cons constructed, while the
last argument to list* becomes the cdr of the last cons
constructed. Hence, any given call to list* always
produces one fewer conses than a call to list with the
same number of arguments.
If the last argument to list* is a list, the effect is
to construct a new list which is similar, but which has
additional elements added to the front corresponding to
the preceding arguments of list*.
If list* receives only one object, that object is returned,
regardless of whether or not it is a list.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 26 Jul 2019 11:24:09 GMT)
Full text and
rfc822 format available.
This bug report was last modified 6 years and 24 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.