From: "Stephen J. Turnbull" <stephen@xemacs.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Juanma Barranquero <lekktu@gmail.com>,
Deniz Dogan <deniz@dogan.se>,
emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r104642: * src/process.c (Fset_process_buffer): Clarify return value in docstring.
Date: Tue, 21 Jun 2011 13:10:28 +0900 [thread overview]
Message-ID: <877h8fakp7.fsf@uwakimon.sk.tsukuba.ac.jp> (raw)
In-Reply-To: <jwv39j4jssn.fsf-monnier+emacs@gnu.org>
Stefan Monnier writes:
> >> Actually, I generally prefer not to document the accidental return value
> >> of side-effecting functions.
>
> > What's accidental in
> > return buffer;
> > ?
>
> That the author could just as well have written "return Qnil;" or
> various other options.
Well, since the DEFUN macro basically requires a return value, and all
functions defined in Lisp do return something, you probably ought to
say that a function should return nil unless there's an obviously good
value to return.
> I can't find a single example of Elisp code in Emacs that does not
> ignore the return value of set-process-buffer (and that's a good thing).
Not necessarily a good thing in Elisp. Like it or not, Elisp has
never made a strong distinction between functions that return values
and functions that have side effects.
While you may prefer the style
(let ((buf (get-buffer-create "buffer for process")))
(set-process-buffer proc buf)
(do-buffing buf))
in Elisp it's common enough to see the style
(do-buffing
(set-process-buffer proc
(get-buffer-create "buffer for process")))
and I don't really see anything wrong with that in Elisp.
Of course as a matter of design, in many cases it's preferable to
return nil now, and think about what a useful return value might be
after we see use cases for the function.
next prev parent reply other threads:[~2011-06-21 4:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1QYeLs-00050O-9O@colonialone.fsf.org>
2011-06-20 14:26 ` [Emacs-diffs] /srv/bzr/emacs/trunk r104642: * src/process.c (Fset_process_buffer): Clarify return value in docstring Stefan Monnier
2011-06-20 16:16 ` Juanma Barranquero
2011-06-20 17:53 ` Stefan Monnier
2011-06-20 19:53 ` Juanma Barranquero
2011-06-21 14:13 ` Stefan Monnier
2011-06-21 14:30 ` Juanma Barranquero
2011-06-21 16:33 ` Stefan Monnier
2011-06-21 16:39 ` Juanma Barranquero
2011-06-21 20:17 ` Deniz Dogan
2011-06-22 1:59 ` Stefan Monnier
2011-06-21 4:10 ` Stephen J. Turnbull [this message]
2011-06-21 16:00 ` Deniz Dogan
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=877h8fakp7.fsf@uwakimon.sk.tsukuba.ac.jp \
--to=stephen@xemacs.org \
--cc=deniz@dogan.se \
--cc=emacs-devel@gnu.org \
--cc=lekktu@gmail.com \
--cc=monnier@iro.umontreal.ca \
/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.