unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Juanma Barranquero <lekktu@gmail.com>, Richard Stallman <rms@gnu.org>
Cc: Eli Zaretskii <eliz@gnu.org>,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	Emacs developers <emacs-devel@gnu.org>
Subject: RE: master a6b5985: Avoid duplicated character classes in rx
Date: Sat, 7 Dec 2019 07:18:36 -0800 (PST)	[thread overview]
Message-ID: <ec7080eb-684a-4d80-8c00-26c33ef47c02@default> (raw)
In-Reply-To: <CAAeL0STTjC1XYhLcuvyaj4WYBOWUG3Q94iyA=82=40abeaVPHQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2748 bytes --]

(BTW - Even a purely functional definition of `push' would return the new stack/list value. And users would of course make use of that return value.)

___

 

Besides the Hyperspec, Common Lisp the Language says this (and it's the case also for the first, 1984 edition, not just CLTL2):

[Macro]
push item place

The form place should be the name of a generalized variable containing a list; item may refer to any Lisp object. The item is consed onto the front of the list, and the augmented list is stored back into place and returned. The form place may be any form acceptable as a generalized variable to setf. If the list held in place is viewed as a push-down stack, then push pushes an element onto the top of the stack. For example:

(setq x '(a (b c) d)) 

(push 5 (cadr x)) => (5 b c)  and now x => (a (5 b c) d)

The effect of (push item place) is roughly equivalent to

(setf place (cons item place))

except that the latter would evaluate any subforms of place twice, while push takes care to evaluate them only once. Moreover, for certain place forms push may be significantly more efficient than the setf version.

 

On Sat, Dec 7, 2019 at 5:48 AM Richard Stallman <HYPERLINK "mailto:rms@gnu.org"rms@gnu.org> wrote:

> What does Common Lisp say about the return value of 'push'?

From the Common Lisp Hyperspec:

 

Macro PUSH

Syntax:

push item place => new-place-value

Arguments and Values:

item---an object.

place---a place, the value of which may be any object.

new-place-value---a list (the new value of place).

Description:

HYPERLINK \l "push prepends item to the list that is stored in place, stores the resulting list in place, and returns the list.

> If Common Lisp describes a certain return value for 'push',
> people will tend to use it that way,

Yes, though as I said, it is very rarely used, at least on our sources. 34 uses out of ~4,100.

There are also a lot like
(and test-1 test-2 ... (push item place))

but don't really depend on the return value of `push', they're just using `and' as a conditional.

 

> and I think it would be a waste of time changing all code that ever depends on that return value.

 

At least for our sources, that time's already been wasted, whether we apply my patch or not.

 

Emacs Lisp is not just for "our sources". It's for Emacs users. What we show as the doc of a function matters for users, not just for Emacs internal developers.

 

> It would be easier to document that return value.

 

Not just easier. Better, including for users.

I tend to agree, because I don't like gratuitously discarding CL compatibility.

[-- Attachment #2: Type: text/html, Size: 11933 bytes --]

  reply	other threads:[~2019-12-07 15:18 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20191203142243.9552.27513@vcs0.savannah.gnu.org>
     [not found] ` <20191203142246.0615C20A2B@vcs0.savannah.gnu.org>
2019-12-03 15:08   ` master a6b5985: Avoid duplicated character classes in rx Juanma Barranquero
2019-12-03 15:26     ` Stefan Monnier
2019-12-03 15:33       ` Mattias Engdegård
2019-12-03 16:01         ` Stefan Monnier
2019-12-03 16:06           ` Juanma Barranquero
2019-12-03 17:37             ` Eli Zaretskii
2019-12-03 17:46               ` Juanma Barranquero
2019-12-03 18:34                 ` Stefan Monnier
2019-12-03 18:12               ` Drew Adams
2019-12-03 17:39             ` Stefan Monnier
2019-12-03 17:51               ` Juanma Barranquero
2019-12-03 18:36                 ` Stefan Monnier
2019-12-03 18:43                   ` Juanma Barranquero
2019-12-04  4:36             ` Richard Stallman
2019-12-04  5:38               ` Juanma Barranquero
2019-12-03 19:20           ` Michael Welsh Duggan
2019-12-03 20:21             ` Stefan Monnier
2019-12-04 11:22           ` Mattias Engdegård
2019-12-06 18:49           ` Juanma Barranquero
2019-12-06 19:45             ` Drew Adams
2019-12-06 20:11               ` Juanma Barranquero
2019-12-10  3:27                 ` Adam Porter
2019-12-10  4:13                   ` Stefan Monnier
2019-12-10  4:20                     ` Adam Porter
2019-12-10  6:09                       ` Juanma Barranquero
2019-12-10  6:32                   ` Juanma Barranquero
2019-12-06 19:46             ` Eli Zaretskii
2019-12-07  4:48             ` Richard Stallman
2019-12-07  5:45               ` Juanma Barranquero
2019-12-07 15:18                 ` Drew Adams [this message]
2019-12-08  5:13                 ` Richard Stallman
2019-12-03 17:39         ` Drew Adams
2019-12-03 15:36       ` Juanma Barranquero

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=ec7080eb-684a-4d80-8c00-26c33ef47c02@default \
    --to=drew.adams@oracle.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=lekktu@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    --cc=rms@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).