bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#16963: A patch to create a list-with-tail primitive.


From: Demetrios Obenour
Subject: bug#16963: A patch to create a list-with-tail primitive.
Date: Fri, 07 Mar 2014 08:58:28 -0500

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]