|
![](/i/fill.gif) |
On 21/04/2012 10:53 PM, Le_Forgeron wrote:
> Le 21/04/2012 23:37, Orchid Win7 v1 nous fit lire :
>> "override operator;".
>
> For once, I'm glad C++ does not allow such!
Well, you'll notice that Haskell only does all this magical stuff IF YOU
EXPLICITLY REQUEST IT. So any block of monadic code either has a big
"do" right at the front of it, or all the ">>=" calls are written
explicitly. Either way, it's pretty obvious that "hey man, something
weird is going to happen here".
Haskell allows you to override many, many things: You can change what
number literals mean. You can change what string literals mean.
Obviously you can change what the various comparison and arithmetic
operators do. Monad in a sense allow you to override the semicolon
operator. You can even override pattern matching. But you know what? It
/doesn't/ let you override function call syntax.
> The overloading (?) of<< and>> is already enough trauma when dealing
> with streams... or not.
You know, considering that C++ demands an explicit type signature on
every tiny little thing... I'm having a hard time imagining how this
would ever be a problem. Especially given that the argument to << is
very, very likely to consist of at least one literal value.
> in fact, monade seems to be the<< with polymorphic type added.
There is a (<<) function in Haskell, in fact, and yes, it's to do with
monads. (It's the same as (>>), but with the arguments swapped around.)
> I wonder if there is a deep difference between haskell& forth... or a
> bit of lisp. Just that haskell dropped all ()...
Haskell dropped the brackets because
1. Functions are first-class, so a "named function" is merely an
ordinary variable who's "value" happens to be a function. So
distinguishing between foo and foo() is not needed.
2. Functions are curried, so foo(1, 2, 3) might run the function and
yield a result, or it might just yield a new, smaller function.
Post a reply to this message
|
![](/i/fill.gif) |