From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Stephen J. Turnbull" Newsgroups: gmane.emacs.devel 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 Message-ID: <877h8fakp7.fsf@uwakimon.sk.tsukuba.ac.jp> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Trace: dough.gmane.org 1308629460 16104 80.91.229.12 (21 Jun 2011 04:11:00 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 21 Jun 2011 04:11:00 +0000 (UTC) Cc: Juanma Barranquero , Deniz Dogan , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 21 06:10:56 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QYsIg-0002fn-Am for ged-emacs-devel@m.gmane.org; Tue, 21 Jun 2011 06:10:54 +0200 Original-Received: from localhost ([::1]:58751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYsIf-0003bO-EL for ged-emacs-devel@m.gmane.org; Tue, 21 Jun 2011 00:10:53 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:49167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYsIO-0003b9-6w for emacs-devel@gnu.org; Tue, 21 Jun 2011 00:10:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QYsIM-0001vs-Kh for emacs-devel@gnu.org; Tue, 21 Jun 2011 00:10:35 -0400 Original-Received: from mgmt1.sk.tsukuba.ac.jp ([130.158.97.223]:36356) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYsIM-0001uD-6N for emacs-devel@gnu.org; Tue, 21 Jun 2011 00:10:34 -0400 Original-Received: from uwakimon.sk.tsukuba.ac.jp (uwakimon.sk.tsukuba.ac.jp [130.158.99.156]) by mgmt1.sk.tsukuba.ac.jp (Postfix) with ESMTP id D06C43FA071F; Tue, 21 Jun 2011 13:10:24 +0900 (JST) Original-Received: by uwakimon.sk.tsukuba.ac.jp (Postfix, from userid 1000) id 4209E12A180; Tue, 21 Jun 2011 13:10:28 +0900 (JST) In-Reply-To: X-Mailer: VM 8.1.93a under 21.5 (beta31) "ginger" cd1f8c4e81cd XEmacs Lucid (x86_64-unknown-linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 130.158.97.223 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:140756 Archived-At: 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.