all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "simenheg@runbox.com" <simenheg@runbox.com>,
	"62027-done@debbugs.gnu.org" <62027-done@debbugs.gnu.org>,
	"manuel@ledu-giraud.fr" <manuel@ledu-giraud.fr>,
	"mardani29@yahoo.es" <mardani29@yahoo.es>
Subject: bug#62027: Subject: 29.0.60; Breaking change in forward-sentence/backward-sentence
Date: Wed, 8 Mar 2023 17:52:54 +0000	[thread overview]
Message-ID: <SJ0PR10MB5488C7A2492507E1CF058F20F3B49@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <83bkl3423v.fsf@gnu.org>

> > > > Should perhaps the return values of
> > > > `forward-sentence'/`backward-sentence' be documented
> > > > to prevent this from happening again?
> > >
> > > Why not: Hyrum's law might have won here.  But OTOH in master,
> > > 'forward-sentence' is a now call to 'forward-sentence-function' that
> > > could be changed by the user.  Maybe should we document
> > > 'forward-sentence-default-function'?
> >
> > Yes, but _both_ should mention the return value.
> > And not just "to prevent this from happening again."
> > Documenting this helps users use the functions.
> 
> Not when the value is a simple consequence
> of the implementation, no.

Are you suggesting that to discover that
the position is returned users need to check
the implementation to see what's returned?

There are plenty of movement functions that
don't return point, even though it's not
obvious that their implementation wouldn't
return point.

How would you guess that `next-line' doesn't
return point, without checking its
implementation?  It seems to go out of its
way to return nil (not point), but it's not
obvious (to me) why that is.

More typically we return nil when a non-nil
value indicates something particular - but
not here.  Or we do so when we specifically,
i.e., for some reason, don't want users to
depend on any particular return value.

Not to mention that to know whether returning
point is "a simple consequence of the
implementation" isn't possible for a command
implemented in C, unless you happen to have
the C source code.

> forward-sentence does its job by side effect,
> not by the value it returns.

If you define "its job" that narrowly, yes.

But then why does it return (point)?  A (happy)
accident/coincidence or design/intended?

In any case, even if you define its job as only
moving, and not also as returning point, that
doesn't prevent it being useful that it returns
the position value.  It's useful to allow/use
code such as this:

(act-on-region some-position
               (forward-sentence N))

rather than

(act-on-region some-position
               (progn (forward-sentence N)
                      (point)))

For setq you could define "its job" as just
changing variable values.  But we return the
value.  Why do we?  Because that's useful.

I don't know why Emacs wouldn't want to let
users know about the useful return value of
a function such as `forward-sentence'.

(By "let users know" I mean help commands,
not just by providing the source code.)

And yes, it wouldn't hurt if _more_ motion
functions (including commands) returned
point. Some do (e.g. `move-beginning-of-line').
Some don't (e.g. `end-of-line', `forward-char').
Probably most don't.

And yes, of course there are motion functions
(e.g. `forward-line') that return a value
other than point - a value that's otherwise
useful.

The point isn't that motion functions should
always return point.  The point is that unless
there's a good reason not to return a useful
value, it's helpful to return a useful value -
and for movement, point can be useful to return.





  reply	other threads:[~2023-03-08 17:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07  7:31 bug#62027: Subject: 29.0.60; Breaking change in forward-sentence/backward-sentence Simen Heggestøyl
2023-03-07  9:35 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-07 11:03   ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-07 13:07     ` Eli Zaretskii
2023-03-07 16:07       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-07 16:17         ` Eli Zaretskii
2023-03-07 16:42           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-07 17:19             ` Eli Zaretskii
2023-03-07 19:07               ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-07 19:32                 ` Eli Zaretskii
2023-03-08  6:50                   ` Simen Heggestøyl
2023-03-08  8:38                     ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-08 15:52                       ` Drew Adams
2023-03-08 16:52                         ` Eli Zaretskii
2023-03-08 17:52                           ` Drew Adams [this message]
2023-03-08 19:46                             ` Eli Zaretskii
2023-03-08 16:51                       ` Eli Zaretskii
2023-03-08 21:02                         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=SJ0PR10MB5488C7A2492507E1CF058F20F3B49@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=62027-done@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=manuel@ledu-giraud.fr \
    --cc=mardani29@yahoo.es \
    --cc=simenheg@runbox.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 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.