all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Stefan Kangas <stefan@marxist.se>, Eli Zaretskii <eliz@gnu.org>
Cc: "28736@debbugs.gnu.org" <28736@debbugs.gnu.org>
Subject: bug#28736: [External] : Re: bug#28736: 24.5; doc of `push'
Date: Sat, 25 Sep 2021 16:43:09 +0000	[thread overview]
Message-ID: <SJ0PR10MB5488D06A685D91CD7F4FED6EF3A59@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <CADwFkmnq3iAq3-e95WqW30oxgqgyLYJ5HLz8hGMwUt0kHrcPJA@mail.gmail.com>

> >> > > 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.
 

  reply	other threads:[~2021-09-25 16:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<<53afe0a4-8ce5-45fc-9e18-6bf52018c9b6@default>
     [not found] ` <<<83h8vatbtk.fsf@gnu.org>
     [not found]   ` <<09655ed0-be2c-4453-9755-224ec733e221@default>
     [not found]     ` <<83wp45sgrm.fsf@gnu.org>
2017-10-08 17:48       ` bug#28736: 24.5; doc of `push' Drew Adams
2017-10-08 18:13         ` Eli Zaretskii
2021-09-25 15:41           ` Stefan Kangas
2021-09-25 16:43             ` Drew Adams [this message]
     [not found] <<53afe0a4-8ce5-45fc-9e18-6bf52018c9b6@default>
     [not found] ` <<83h8vatbtk.fsf@gnu.org>
2017-10-08 16:50   ` Drew Adams
2017-10-08 17:15     ` Eli Zaretskii
2017-10-08  2:56 Drew Adams
2017-10-08  6:04 ` Eli Zaretskii

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=SJ0PR10MB5488D06A685D91CD7F4FED6EF3A59@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=28736@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=stefan@marxist.se \
    /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.