unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Demetrios Obenour <demetriobenour@gmail.com>
To: 16963@debbugs.gnu.org
Subject: bug#16963: A patch to create a list-with-tail primitive.
Date: Fri, 07 Mar 2014 08:58:28 -0500	[thread overview]
Message-ID: <1394200708.1710.4.camel@localhost.localdomain> (raw)

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	other threads:[~2014-03-07 13:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-07 13:58 Demetrios Obenour [this message]
2014-03-25  2:10 ` bug#16963: A patch to create a list-with-tail primitive 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394200708.1710.4.camel@localhost.localdomain \
    --to=demetriobenour@gmail.com \
    --cc=16963@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).