GNU bug report logs - #28736
24.5; doc of `push'

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Sun, 8 Oct 2017 02:58:01 UTC

Severity: wishlist

Tags: notabug, wontfix

Found in version 24.5

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 28736 in the body.
You can then email your comments to 28736 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#28736; Package emacs. (Sun, 08 Oct 2017 02:58:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Drew Adams <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 08 Oct 2017 02:58:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.5; doc of `push'
Date: Sat, 7 Oct 2017 19:56:58 -0700 (PDT)
Both the doc string and the Elisp manual entry should say that `push'
returns the new value of the place that it updates.  The doc says
nothing about the return value.

The return value is implied by the doc, which says that `push' is
"morally equivalent" to (setf PLACE (cons NEWELT PLACE)), and one
Can figure out that `setf' returns the new value.  But the doc should
just say explicitly what the return value is, instead of making users
dig it out or check the code.

  This is morally equivalent to (setf PLACE (cons NEWELT PLACE)),
  except that PLACE is only evaluated once (after NEWELT).

Also, the use of "morally equivalent" here, though perhaps intended to
be cute, as a joke of sorts, is inappropriate and possibly confusing.
What matters is that the behavior and return value are equivalent, with
the proviso mentioned: that PLACE is evaluated only once (after NEWELT).


In GNU Emacs 24.5.1 (i686-pc-mingw32)
 of 2015-04-11 on LEG570
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/usr --host=i686-pc-mingw32'




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28736; Package emacs. (Sun, 08 Oct 2017 06:05:02 GMT) Full text and rfc822 format available.

Message #8 received at 28736 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 28736 <at> debbugs.gnu.org
Subject: Re: bug#28736: 24.5; doc of `push'
Date: Sun, 08 Oct 2017 09:04:23 +0300
> Date: Sat, 7 Oct 2017 19:56:58 -0700 (PDT)
> From: Drew Adams <drew.adams <at> oracle.com>
> 
> Both the doc string and the Elisp manual entry should say that `push'
> returns the new value of the place that it updates.  The doc says
> nothing about the return value.

That usually means we don't want to advertise the return value, and
that programs should not depend on it.  Why is that a problem in this
case?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28736; Package emacs. (Sun, 08 Oct 2017 16:51:01 GMT) Full text and rfc822 format available.

Message #11 received at 28736 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Drew Adams <drew.adams <at> oracle.com>
Cc: 28736 <at> debbugs.gnu.org
Subject: RE: bug#28736: 24.5; doc of `push'
Date: Sun, 8 Oct 2017 09:50:37 -0700 (PDT)
> > Both the doc string and the Elisp manual entry should say that `push'
> > returns the new value of the place that it updates.  The doc says
> > nothing about the return value.
> 
> That usually means

Usually? Maybe. In this case? Who knows?

> we don't want to advertise the return value, and
> that programs should not depend on it.

Well, now, that would be quite strange in this case. This
is taken directly from Common Lisp (with some functionality
lost), where it is not only prominently documented but it
has also been widely used - for decades.

> Why is that a problem in this case?

No. The right question is why is it a problem to document
this?  This is an important part of the behavior of the
macro. Why should we _not_ inform users about this useful
feature?

This is no different (zero difference, in fact) from
documenting that `setq' returns the value of its (last)
assignment.

(Not to mention that we document the return value of `pop'.)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28736; Package emacs. (Sun, 08 Oct 2017 17:16:01 GMT) Full text and rfc822 format available.

Message #14 received at 28736 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 28736 <at> debbugs.gnu.org
Subject: Re: bug#28736: 24.5; doc of `push'
Date: Sun, 08 Oct 2017 20:15:09 +0300
> Date: Sun, 8 Oct 2017 09:50:37 -0700 (PDT)
> From: Drew Adams <drew.adams <at> oracle.com>
> Cc: 28736 <at> debbugs.gnu.org
> 
> > Why is that a problem in this case?
> 
> No. The right question is why is it a problem to document
> this?

<Shrug> Because we don't want to guarantee the return value won't
change in the future?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28736; Package emacs. (Sun, 08 Oct 2017 17:49:01 GMT) Full text and rfc822 format available.

Message #17 received at 28736 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 28736 <at> debbugs.gnu.org
Subject: RE: bug#28736: 24.5; doc of `push'
Date: Sun, 8 Oct 2017 10:48:32 -0700 (PDT)
> > The right question is why is it a problem to document this?
> 
> <Shrug> Because we don't want to guarantee the return value won't
> change in the future?

Are you sure?  When was that decided?  Just now?

Why would we want to do that?  Gratuitously acting different
from Common Lisp (and all other Lisps?) in this case wouldn't
seem to be advantageous.  Do you see a good reason to do that?

And why "<Shrug>"?  I wonder if your answer might have been
different if a different person had filed this bug...




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28736; Package emacs. (Sun, 08 Oct 2017 18:14:02 GMT) Full text and rfc822 format available.

Message #20 received at 28736 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 28736 <at> debbugs.gnu.org
Subject: Re: bug#28736: 24.5; doc of `push'
Date: Sun, 08 Oct 2017 21:13:15 +0300
> Date: Sun, 8 Oct 2017 10:48:32 -0700 (PDT)
> From: Drew Adams <drew.adams <at> oracle.com>
> Cc: 28736 <at> debbugs.gnu.org
> 
> > > The right question is why is it a problem to document this?
> > 
> > <Shrug> Because we don't want to guarantee the return value won't
> > change in the future?
> 
> Are you sure?

No.

> When was that decided?

I don't know if it was decided and when, I was just wondering whether
the lack of documentation is deliberate or an omission.

> Just now?

That's uncalled-for.

> And why "<Shrug>"?  I wonder if your answer might have been
> different if a different person had filed this bug...

Why would you wonder about that?  Have I ever treated your bug reports
different from anyone else's?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28736; Package emacs. (Sun, 08 Oct 2017 19:41:01 GMT) Full text and rfc822 format available.

Message #23 received at 28736 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 28736 <at> debbugs.gnu.org
Subject: RE: bug#28736: 24.5; doc of `push'
Date: Sun, 8 Oct 2017 12:40:08 -0700 (PDT)
> > > > why is it a problem to document this?
> > >
> > > <Shrug> Because we don't want to guarantee the return
> > > value won't change in the future?
> >
> > Are you sure?
> 
> No.
> 
> > When was that decided?
> 
> I don't know if it was decided and when, I was just wondering
> whether the lack of documentation is deliberate or an omission.

Good.  Neither do I know that we don't want to guarantee
that the return value won't change.  Nor do I know whether
the lack of documentation was deliberate or not.  Nor do I
know a reason why we wouldn't want to document the behavior,
guarantee or no guarantee. 

Not having any reason to think there was a deliberate
decision not to document this, and not knowing any good
reason why it should not be documented, whether it was
deliberate or (a priori more likely) an oversight, and
knowing good reasons why it _should_ be documented (it
is useful, and documenting that use is the practice in
Lisp in general, and it fits what we do for things like
`setq'), this should be a no-brainer, IMO.

But if there is a good reason why it should not be
documented, let's hear it, please.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28736; Package emacs. (Mon, 09 Oct 2017 06:57:01 GMT) Full text and rfc822 format available.

Message #26 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#28736: 24.5; doc of `push'
Date: Mon, 9 Oct 2017 09:13:04 +0200
[Message part 1 (text/plain, inline)]

On 08.10.2017 21:40, Drew Adams wrote:
>>>>> why is it a problem to document this?
>>>> <Shrug> Because we don't want to guarantee the return
>>>> value won't change in the future?
>>> Are you sure?
>> No.
>>
>>> When was that decided?
>> I don't know if it was decided and when, I was just wondering
>> whether the lack of documentation is deliberate or an omission.
> Good.  Neither do I know that we don't want to guarantee
> that the return value won't change.  Nor do I know whether
> the lack of documentation was deliberate or not.  Nor do I
> know a reason why we wouldn't want to document the behavior,
> guarantee or no guarantee.
>
> Not having any reason to think there was a deliberate
> decision not to document this, and not knowing any good
> reason why it should not be documented, whether it was
> deliberate or (a priori more likely) an oversight, and
> knowing good reasons why it _should_ be documented (it
> is useful, and documenting that use is the practice in
> Lisp in general, and it fits what we do for things like
> `setq'), this should be a no-brainer, IMO.
>
> But if there is a good reason why it should not be
> documented, let's hear it, please.
>
>
>

+1
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28736; Package emacs. (Sat, 25 Sep 2021 15:42:02 GMT) Full text and rfc822 format available.

Message #29 received at 28736 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 28736 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#28736: 24.5; doc of `push'
Date: Sat, 25 Sep 2021 08:41:01 -0700
tags 28736 wontfix notabug
close 28736
thanks

Eli Zaretskii <eliz <at> gnu.org> writes:

>> Date: Sun, 8 Oct 2017 10:48:32 -0700 (PDT)
>> From: Drew Adams <drew.adams <at> oracle.com>
>> Cc: 28736 <at> debbugs.gnu.org
>>
>> > > The right question is why is it a problem to document this?
>> >
>> > <Shrug> Because we don't want to guarantee the return value won't
>> > change in the future?
>>
>> Are you sure?
>
> No.

The question here is if the return value of `push' should be documented.

I took a look at Common Lisp, and they do not document its return
value.[1]  I think it's fine for us to also not document it, unless someone
can show a clear reason why it should be.

I'm therefore closing this bug report.

Footnotes:
[1]  http://clhs.lisp.se/Body/m_push.htm




Added tag(s) wontfix and notabug. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sat, 25 Sep 2021 15:42:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 28736 <at> debbugs.gnu.org and Drew Adams <drew.adams <at> oracle.com> Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sat, 25 Sep 2021 15:42:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28736; Package emacs. (Sat, 25 Sep 2021 16:44:01 GMT) Full text and rfc822 format available.

Message #36 received at 28736 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Stefan Kangas <stefan <at> marxist.se>, Eli Zaretskii <eliz <at> gnu.org>
Cc: "28736 <at> debbugs.gnu.org" <28736 <at> debbugs.gnu.org>
Subject: RE: [External] : Re: bug#28736: 24.5; doc of `push'
Date: Sat, 25 Sep 2021 16:43:09 +0000
> >> > > The right question is why is it a problem to document this?
> >> >
> >> > <Shrug> Because we don't want to guarantee the return value won't
> >> > change in the future?
> >>
> >> Are you sure?
> >
> > No.
> 
> The question here is if the return value of `push' should be
> documented.
> 
> I took a look at Common Lisp, and they do not document its return
> value.[1]  I think it's fine for us to also not document it, unless
> someone can show a clear reason why it should be.
> 
> I'm therefore closing this bug report.
> Footnotes:
> [1] http://clhs.lisp.se/Body/m_push.htm

Don't look to the Common Lisp Hyperspec as a complete
definition of the language.  It's just a quick way to
get some info (IMO).

Common Lisp The Language (2nd edition) is where to
look.  Especially for design choices, semantics, and
reasons behind the design.

CLTL2 says this about `push' (similarly `pushnew'):

 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.

And what is the effect of `setf' with a cons?  CLTL2
tells us:

 The ultimate result of evaluating a setf form is the
 value of newvalue.

`setf', in all its myriad possibilities, including
user-defined setf methods, is, I think, specified as
returning the new (just set) value.

I agree that the Common Lisp doc could be more explicit
about this, but my reading of it is that `push' returns
the new value - that's part of its specified behavior.

Other readers may disagree.

For `push': 

https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node149.html

For `setf':

https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node80.html

Examples (`push', `setf'):

https://www.csee.umbc.edu/courses/331/resources/lisp/LISP-tutorial.html#Setf

___

Note, however, that some things that `setf' _replaced_
in Common Lisp, such as `setcar', do NOT return the
thing updated. `setcar' returns the new car, not the
updated cons.
 

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 24 Oct 2021 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 241 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.