From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: if vs. when vs. and: style question Date: Tue, 24 Mar 2015 00:19:11 +0100 Organization: Aioe.org NNTP Server Message-ID: <878uen1evk.fsf@debian.uxu> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1427152835 31456 80.91.229.3 (23 Mar 2015 23:20:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 23 Mar 2015 23:20:35 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 24 00:20:33 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YaBdr-0002Nu-Ll for geh-help-gnu-emacs@m.gmane.org; Tue, 24 Mar 2015 00:20:19 +0100 Original-Received: from localhost ([::1]:58408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YaBdq-0004l1-SM for geh-help-gnu-emacs@m.gmane.org; Mon, 23 Mar 2015 19:20:18 -0400 Original-Path: usenet.stanford.edu!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 44 Original-NNTP-Posting-Host: feB02bRejf23rfBm51Mt7Q.user.speranza.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:0n2zJh8tP7vll8KnYm6/Lzy3t5o= Mail-Copies-To: never Original-Xref: usenet.stanford.edu gnu.emacs.help:210994 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:103275 Archived-At: Marcin Borkowski writes: > assuming (e1) and (e2) are some expressions, all > three forms: > > (if (e1) (e2)) > > (when (e1) (e2)) > > (and (e1) (e2)) > > are semantically equivalent. Which one is better > style (and when)? I would guess that =when= is > better iff (e2) is a =progn= (since we can drop the > =progn= altogether, and this seems to be the point > of =when=), and =and= might be considered better > (well, maybe) by some people when both (e1) and (e2) > are very short (though I personally would avoid > that, since =if= seems easier for a human to > understand at a first glance). Am I right? I don't think `and' should be used to evaluate and return =stuff= (I mean evaluate as in side-effects), rather, use it as the familiar gate of binary logic, thought here it isn't binary but can be of whatever arity. But no rule without exceptions, of course... To me `if' + `progn' is better than `when' because I am more familiar with those constructs and also, if I ever have to change something, which happens all the time, I will not have to bother thinking "is this still a `progn'? if it isn't, should I remove the `when'? if I don't, will anyone wonder why I used a `when' instead of `if'? Less thinking, more coding I'd say with plain `if' and then whatever is needed from there to get it done. But I can't say I'd hit the ceiling if anyone used `when', with or without the need for a `progn' in the equivalent `if' clause. Using `and' for no reason I'd consider worse because that could be really confusing. -- underground experts united