all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Ivan Shmakov <ivan@siamics.net>, 18175@debbugs.gnu.org
Subject: bug#18175: files.el: use mapc in (mapcar 'switch-to-buffer ...)
Date: Sun, 3 Aug 2014 09:32:29 -0700 (PDT)	[thread overview]
Message-ID: <77fd6f4e-8cfd-49d1-884e-c61ce7a075a3@default> (raw)
In-Reply-To: <87mwbmeyva.fsf@violet.siamics.net>

>  > By using `mapcar' you are signaling that you are interested in the
>  > return values of the argument function (and of course the resulting
>  > list of them).
> 
>  > By using `mapc' you are signaling that the values returned by the
>  > argument function are unimportant (only its side effects are
>  > significant).
> 
> 	How do you signal that the values returned by the argument
> 	function are unimportant, /and/ that you’re interested in the
> 	/original/ list instead?

By doing what you've done now.  Neither `mapc' nor `mapcar' says
that, on its own.

If return values are not important in some code then `mapc`,
`dolist`, `while`, or any number of other imperative/procedural
approaches are fine to use, and are often preferable.

Looking briefly at the original code and your patches now, I am
reminded that `find-file*' needs to return the list of buffers
(or the single buffer, for that case).  (As one user, for example,
I have code that expects the list of buffers to be returned.)

Your new patch does that, and it looks OK to me.  I did not spend
much time looking things over, so I might be missing something,
but it looks like you are not changing the external behavior (good).

It is fine to optimize things, but function interfaces (signatures
and behavior as viewed by calling functions or by users) should
not be altered.

You might want to make sure that the list of buffers returned is
the same in all cases as what is returned today.  The doc string
of `switch-to-buffer', for instance, seems to make a point of
saying that it returns the buffer switched to.  It does not say
that it returns the buffer indicated by argument BUFFER-OR-NAME.
Dunno why, but it does.

I'm guessing that that can make a difference only if the intended
buffer cannot be switched to (an error is raised).  And in that
case I'm guessing that the error raised would be handled
correctly by `find-file*'.  (I have not checked.)

You might also want to check to be sure that the effect on what
`buffer-list' returns (after the calls to `switch-buffer*')
remains the same.

The calls to `switch-to-buffer*' here do not use non-nil NORECORD,
so that at least can be ignored.  But maybe take a look, to make
sure.  Some commands and other functions depend on the buffer
order in `buffer-list', so this too should not be altered by
your proposed change.





  reply	other threads:[~2014-08-03 16:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-02 21:55 bug#18175: files.el: use mapc in (mapcar 'switch-to-buffer ...) Ivan Shmakov
2014-08-03  0:55 ` Drew Adams
2014-08-03  8:55   ` Ivan Shmakov
2014-08-03 16:32     ` Drew Adams [this message]
2014-08-03 18:25       ` Ivan Shmakov
2014-08-03 18:43         ` Drew Adams
2014-08-06 17:26 ` Stefan Monnier
2014-08-07 19:15   ` Ivan Shmakov
2014-08-07 19:29     ` Stefan Monnier
2015-01-23 15:27       ` Ivan Shmakov

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=77fd6f4e-8cfd-49d1-884e-c61ce7a075a3@default \
    --to=drew.adams@oracle.com \
    --cc=18175@debbugs.gnu.org \
    --cc=ivan@siamics.net \
    /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.