On 7/27/06, Dan Doel <[EMAIL PROTECTED]> wrote:
On 7/26/06, Donn Cave <[EMAIL PROTECTED]> wrote:
> That looks to me like a different way to spell if then else, but maybe
> that's the answer to the question - conceptually, for every "then" there
> really is an "else", however you spell it, and only in a procedural language
> does it make any sense to leave it implicit. The exception that proves the
> rule is "else return ()" -, e.g.,
...
> Strictly speaking that generalizes to any functional context where a generic
> value can be assigned to the else clause, but there don't tend to be that
> many other such contexts. Does that answer the question?
I believe his question was why if-then-else is syntax, rather than the
function he gave. Since haskell is non-strict, it doesn't need to be
implemented as syntax (unlike, say, scheme, where it needs to be a
special form/macro to avoid executing both branches).
I imagine the answer is that having the syntax for it looks nicer/is
clearer. "if a b c" could be more cryptic than "if a then b else c"
for some values of a, b and c.
Also, you get less parenthesis:
myAbs x = if x < 0 then negate x else x
/S
--
Sebastian Sylvan
+46(0)736-818655
UIN: 44640862
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe