[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: if vs. when vs. and: style question
From: |
Rusi |
Subject: |
Re: if vs. when vs. and: style question |
Date: |
Tue, 24 Mar 2015 19:35:53 -0700 (PDT) |
User-agent: |
G2/1.0 |
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)
- Re: if vs. when vs. and: style question, (continued)
- Re: if vs. when vs. and: style question, Pascal J. Bourguignon, 2015/03/27
- Re: if vs. when vs. and: style question, Emanuel Berg, 2015/03/26
- Re: if vs. when vs. and: style question, Gian Uberto Lauri, 2015/03/27
- Message not available
- Re: if vs. when vs. and: style question, Joost Kremers, 2015/03/27
- Message not available
- Re: if vs. when vs. and: style question, Pascal J. Bourguignon, 2015/03/27
- Re: if vs. when vs. and: style question, Rusi, 2015/03/27
- Re: if vs. when vs. and: style question,
Rusi <=
- Re: if vs. when vs. and: style question, Emanuel Berg, 2015/03/26
- Re: if vs. when vs. and: style question, Emanuel Berg, 2015/03/27
- Re: if vs. when vs. and: style question, Pascal J. Bourguignon, 2015/03/27
- Re: if vs. when vs. and: style question, Rusi, 2015/03/27
- Re: if vs. when vs. and: style question, Pascal J. Bourguignon, 2015/03/28
- Re: if vs. when vs. and: style question, Pascal J. Bourguignon, 2015/03/24
- Re: if vs. when vs. and: style question, Emanuel Berg, 2015/03/24
Re: if vs. when vs. and: style question, Thien-Thi Nguyen, 2015/03/24
Message not available
Re: if vs. when vs. and: style question, Emanuel Berg, 2015/03/23