all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#16963: A patch to create a list-with-tail primitive.
@ 2014-03-07 13:58 Demetrios Obenour
  2014-03-25  2:10 ` Stefan
  2016-02-24  2:51 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 13+ messages in thread
From: Demetrios Obenour @ 2014-03-07 13:58 UTC (permalink / raw)
  To: 16963

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






^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-06-28  3:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-07 13:58 bug#16963: A patch to create a list-with-tail primitive Demetrios Obenour
2014-03-25  2:10 ` Stefan
2014-03-25  2:45   ` Daniel Colascione
2014-03-27 23:37     ` Demetrios Obenour
2014-03-27 23:38       ` Daniel Colascione
2014-03-28  0:43         ` Demetrios Obenour
2014-03-29  1:46         ` Demetrios Obenour
2014-03-29  1:48           ` Daniel Colascione
2014-03-29 13:30             ` Demetrios Obenour
2016-02-24  2:51 ` Lars Ingebrigtsen
2019-06-26 14:30   ` Lars Ingebrigtsen
2019-06-28  3:14     ` Noam Postavsky
2019-06-28  3:30       ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.