From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rusi Newsgroups: gmane.emacs.help Subject: Re: if vs. when vs. and: style question Date: Tue, 24 Mar 2015 19:35:53 -0700 (PDT) Message-ID: <828c5115-a61b-4c42-b6d5-7bdcc6a691f0@googlegroups.com> References: <87sicvwckx.fsf@wmi.amu.edu.pl> <87wq27yvqg.fsf@debian.uxu> <8d531e99-7260-4263-ac99-09c6871e2708@googlegroups.com> <87vbhq53lf.fsf@debian.uxu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1427251323 775 80.91.229.3 (25 Mar 2015 02:42:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 Mar 2015 02:42:03 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Mar 25 03:41:59 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 1YabGY-0008Lp-Ee for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Mar 2015 03:41:58 +0100 Original-Received: from localhost ([::1]:35801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YabGX-00015a-Ls for geh-help-gnu-emacs@m.gmane.org; Tue, 24 Mar 2015 22:41:57 -0400 X-Received: by 10.66.136.175 with SMTP id qb15mr8336670pab.11.1427250953687; Tue, 24 Mar 2015 19:35:53 -0700 (PDT) X-Received: by 10.50.141.134 with SMTP id ro6mr145469igb.0.1427250953650; Tue, 24 Mar 2015 19:35:53 -0700 (PDT) Original-Path: usenet.stanford.edu!z20no3006775igj.0!news-out.google.com!db6ni62281igc.0!nntp.google.com!z20no4556839igj.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: <87vbhq53lf.fsf@debian.uxu> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=117.195.63.242; posting-account=mBpa7woAAAAGLEWUUKpmbxm-Quu5D8ui Original-NNTP-Posting-Host: 117.195.63.242 User-Agent: G2/1.0 Injection-Date: Wed, 25 Mar 2015 02:35:53 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:211024 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:103305 Archived-At: On Wednesday, March 25, 2015 at 5:47:31 AM UTC+5:30, Emanuel Berg wrote: > Rusi writes: > > > In general weaker is better > > http://www.w3.org/2001/tag/doc/leastPower.html > > > > (when a b) ... (if a b) However (if a b c) ... (when ??) > > What do you mean by "weaker"? [At the risk of being over-simplistic...] Weaker means less flexible Maybe this link is more programmer-oriented than the earlier (web-oriented) one http://blog.higher-order.com/blog/2014/12/21/maximally-powerful/ > > `if' can do three arguments, on the other hand it > needs a `progn' to do several forms. `when' comes with > implicit progn but cannot do the three way > if-else if-else branch. > > What I can see `if' is more flexible and you can > change things without having to change the outermost > `if', which is practical. Yes, with the use of `not' > and `progn' if necessary, but I don't see a problem > with that. > > > Other example: > > > > destructuring-bind is strictly weaker than if/cond > > and so better when usable > > What is "destructuring-bind"? I guess not a very good example. Pattern-matching in modern FPLs would be more appropriate foo [] = bla foo (x:xs) = ble Can always be translated into foo l = if null l then bla else ble The reverse is of course not always possible But when pattern matching works its preferable to 'all-powerful' if-then-else Notice also that pattern matching is a mix of 3 features that are usually separate -- 1. if 2. let 3. car/cdr ie selectors Separately those 3 are strictly more powerful than pattern matching And thats what makes pattern matching preferable (when it applies)