unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: [RFC] caar/cadr/cdar/cddr
Date: Thu, 12 Jul 2012 10:47:42 -0600	[thread overview]
Message-ID: <87ehohc4ep.fsf@fleche.redhat.com> (raw)
In-Reply-To: <4FFEFA98.3060509@yandex.ru> (Dmitry Antipov's message of "Thu, 12 Jul 2012 20:26:00 +0400")

>>>>> "Dmitry" == Dmitry Antipov <dmantipov@yandex.ru> writes:

Dmitry> These are widely used, so why not doing them as C primitives and
Dmitry> corresponding bytecodes?  It shouldn't be too hard to tweak
Dmitry> byte-opt.el to optimize (car (cdr X)) -> (cadr X) etc., and so
Dmitry> emit new bytecodes.

Did you try to measure the performance benefit?

Dmitry> +(byte-defop 48   0 byte-caar)
Dmitry> +(byte-defop 49   0 byte-cadr)
Dmitry> +(byte-defop 50   0 byte-cdar)
Dmitry> +(byte-defop 51   0 byte-cddr)

Occasionally I wish we were sharing these definitions with bytecode.c;
or more generally that parts of the Emacs core could be written in some
form of Lisp.

Dmitry> + loop:
Dmitry> +  if (CONSP (tem))
Dmitry> +    {
Dmitry> +      if (!EQ (tem, list))
Dmitry> +	return XCAR (tem);
Dmitry> +      tem = XCDR (tem);
Dmitry> +      goto loop;
Dmitry> +    }
Dmitry> +  else return NILP (tem) ? Qnil : wrong_type_argument (Qlistp, tem);

All these functions are implemented in what seems, to me, a very weird
way.  Why not just write the obvious straight-line code?

Tom



  reply	other threads:[~2012-07-12 16:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-12 16:26 [RFC] caar/cadr/cdar/cddr Dmitry Antipov
2012-07-12 16:47 ` Tom Tromey [this message]
2012-07-12 16:53 ` Tom Tromey
2012-07-12 16:53 ` Paul Eggert
2012-07-12 17:44   ` Dmitry Antipov
2012-07-12 21:46     ` Samuel Bronson
2012-07-12 22:43     ` Paul Eggert
2012-07-12 23:08     ` Alp Aker
2012-07-13  0:12     ` Stefan Monnier
2012-07-13  1:27       ` Samuel Bronson
2012-07-13 12:05         ` Stefan Monnier

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=87ehohc4ep.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=dmantipov@yandex.ru \
    --cc=emacs-devel@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).