unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Nicolas Petton <nicolas@petton.fr>,
	Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: Tom Tromey <tom@tromey.com>, emacs-devel@gnu.org
Subject: RE: map-put! and (setf (map-elt ...) ..) on lists
Date: Tue, 18 Dec 2018 07:34:02 -0800 (PST)	[thread overview]
Message-ID: <150bbe9c-3ef4-4d43-9fce-23d608abd829@default> (raw)
In-Reply-To: <87bm5jm9eu.fsf@petton.fr>

> > Do we have a non-destructive `map-put'?
> 
> There's `map-insert'.

My point was that there is no need for a function
name to signal that the function so named is
"destructive".  The doc string should do that,
however.

The only case where we might need a function name
to signal this is when we have two functions with
exactly the same name otherwise, one "destructive"
and the other not.

There is macro `map-put', which is supposedly
obsolete now.  It would be fine (IMHO) to just
name the new, "destructive" function `map-put',
IOW replace the macro that is anyway obsolete.

If we did that we'd need to post a notice (in
NEWS and the doc string, for example) that we've
made such an incompatible change.  Probably not
a big deal.

> > Much more important than the function name, however, is
> > the real answer: Put the important info in the doc string.
> 
> The docstring, yes, of course, but the function name is IMHO the most
> important part of the documentation.

The function name should, yes, say what the function
does.  But it need not always say how it does it or
whether the action might change list structure etc.

Or if it does then that should be done systematically,
for the names of all "destructive" functions.  It is
misleading in Lisp to have some "destructive" functions
signal that fact in their names, and others not do so.

And as I said, if you use such a function in a function
you define, it can often be the case that your function
is, likewise, "destructive". Are you going to name your
function using such a name signal too?  And so on.  It's
a contagious virus, which we generally ignore, in terms
of propagating such a name convention.

Again, just one, no doubt minority, opinion.  I express
the opinion, but I don't expect that it will have much
effect.
 
> As I said, I like Stefan's approach, but if everybody else dislike it,
> and if you think it's not idiomatic Elisp, then let's change the name.
> 
> Stefan, would it be ok with you?

I don't think there is a standard idiom.  Some names
indicate (if a user knows the particular convention)
possible "destruction", but others do not.

An old user might recognize that `nreverse' is a
"destructive" `reverse' from the name, but a new user
might not.  The doc should be the place where we make
very clear what a function does and whether it is
"destructive".

If Emacs does want to follow a convention of naming
"destructive" functions then it should do so more
systematically, IMO.  (And IMO it should not bother
to do so.)  In that case, apply the convention all
over the place, even including renaming (but keeping
an old alias) functions such as `nreverse'.



  parent reply	other threads:[~2018-12-18 15:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-14 17:32 map-put! and (setf (map-elt ...) ..) on lists Stefan Monnier
2018-12-16 16:32 ` Tom Tromey
2018-12-16 17:37   ` Drew Adams
2018-12-16 18:20     ` Stefan Monnier
2018-12-16 23:06       ` Tom Tromey
2018-12-17  3:16         ` Stefan Monnier
2018-12-17  4:08       ` Stefan Monnier
2018-12-17 11:41         ` Nicolas Petton
2018-12-17 16:06           ` Eli Zaretskii
2018-12-17 16:07           ` Drew Adams
2018-12-18 10:11             ` Nicolas Petton
2018-12-18 13:56               ` Stefan Monnier
2018-12-18 15:42                 ` Drew Adams
2018-12-18 15:34               ` Drew Adams [this message]
2018-12-18 15:47                 ` Stefan Monnier
2018-12-18 16:34                 ` Nicolas Petton
2018-12-18 17:41                   ` Drew Adams
2018-12-18 20:44                     ` Nicolas Petton
2018-12-16 18:21     ` Stefan Monnier
2018-12-17 11:38 ` Nicolas Petton

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=150bbe9c-3ef4-4d43-9fce-23d608abd829@default \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    --cc=nicolas@petton.fr \
    --cc=tom@tromey.com \
    /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).