all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: Why aren't `find`, `find-if`, `remove-if` part of Emacs Lisp?
Date: Wed, 25 Jun 2014 10:09:53 -0400	[thread overview]
Message-ID: <jwvr42dt847.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: wfkeionpthgo.fsf@sap.com

> That might be a description of todays implementation.  I would assume
> that you could compile away the keyword parameters relativly easily: you
> basically attach a define-compiler-macro (another CL macro) which maps
> the keyword parameters to positional parameters.

There's another problem with CL in this area: it tries to reproduce
(as faithfully as possible) the CL semantics, but in some cases, that
semantics doesn't *quite* match the Elisp semantics, so they have to
work much harder even if in 99% of the cases the difference is not
actually relevant.  E.g. in Elisp a missing optional argument is 100%
equivalent to a nil argument, whereas CL's optional argument can
distinguish the two cases, so an "&optional (x 3)" will have to be
macroexpanded into a "&rest args" and then checking the length of args
to see if the arg was provided or not.

If we were to add support for "&optional (x 3)" to Elisp, we'd either
need to change the C code that implements optional arguments, as well as
the byte-code format, so as to make the distinction between a nil and
a missing argument efficient (and get CL's semantics), or we'd just use
a simple macro-expansion approach and declare that nil is the same as
a missing argument: much simpler to implement and more in line with
usual Elisp practice.

This has happened time and time again: when Elisp incorporated a feature
present in cl.el, it typically did it in a slightly different way.
And usually the reasons are a mix of:
- because implementation simplicity is of utmost importance (given the
  lack of resources).
- because Elisp is not Common-Lisp, so the conventions, traditions, and
  expectations aren't quite the same.
- because we found a better way (e.g. compare gv-define-expander to
  define-setf-method).

Regarding macros and APIs, an important difference between Common-Lisp
and Elisp is that the expansion of a macro can only use "stable API
functions".  E.g. we can't just say "to modify this property, use (setf
<foo> ...)" and then consider the macro-expansion's result to be "an
internal detail that we can change at will" because the macroexpanded
code will be cast in stone in a foo.elc file that the user may still
want to use with Emacs-35.

So whichever setter function this `setf' method chose to use will have
to be preserved for many years.  We may elect not to advertise this
setter function, but even if we don't advertise it, we'll have to keep
supporting it to some extent.


        Stefan


  parent reply	other threads:[~2014-06-25 14:09 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-17 17:13 Why aren't `find`, `find-if`, `remove-if` part of Emacs Lisp? Nicolas Petton
2014-06-17 17:28 ` Stefan Monnier
2014-06-17 18:36   ` Nicolas Petton
2014-06-17 18:56     ` Doug Lewan
2014-06-17 19:06       ` Nicolas Petton
2014-06-17 19:55         ` Doug Lewan
2014-06-17 22:16     ` Stefan Monnier
2014-06-18 11:00       ` Nicolas Petton
     [not found]       ` <mailman.3879.1403089222.1147.help-gnu-emacs@gnu.org>
2014-06-18 14:36         ` Stefan Monnier
2014-06-18 14:43         ` Barry Margolin
2014-06-18 15:43           ` Damien Cassou
2014-06-18 16:31             ` Phillip Lord
     [not found]           ` <mailman.3896.1403106263.1147.help-gnu-emacs@gnu.org>
2014-06-24 13:51             ` Christoph Wedler
2014-06-24 16:24               ` Barry Margolin
2014-06-25  3:22                 ` Stefan Monnier
2014-06-25  4:08                   ` Leo Liu
     [not found]                   ` <mailman.4252.1403669342.1147.help-gnu-emacs@gnu.org>
2014-06-25 13:46                     ` Stefan Monnier
     [not found]                 ` <mailman.4251.1403666567.1147.help-gnu-emacs@gnu.org>
2014-06-25 10:24                   ` Christoph Wedler
2014-06-25 13:35                     ` Stefan Monnier
2014-06-25 14:09                     ` Stefan Monnier [this message]
2014-06-25 15:37                     ` Barry Margolin
2014-06-25 23:44                       ` Robert Thorpe
2014-06-18 14:43         ` Pascal J. Bourguignon
     [not found] ` <mailman.3837.1403026153.1147.help-gnu-emacs@gnu.org>
2014-06-20  0:20   ` WJ
2014-06-20 13:45     ` Stefan Monnier
     [not found] <mailman.3836.1403025251.1147.help-gnu-emacs@gnu.org>
2014-06-17 21:42 ` Barry Margolin
     [not found] <mailman.4322.1403739913.1147.help-gnu-emacs@gnu.org>
2014-06-26  0:37 ` Stefan Monnier
2014-06-26  5:27 ` Barry Margolin

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

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

  git send-email \
    --in-reply-to=jwvr42dt847.fsf-monnier+gnu.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@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 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.