[chuck-users] wishlist for the new year
haberg at math.su.se
Mon Jan 11 15:49:40 EST 2010
On 11 Jan 2010, at 19:19, mike clemow wrote:
> All I was saying originally, however, was that we should overload
> @=> to be able to reassign functions themselves to other references.
> fun void foo(int i)
> <<< i >>>;
> foo @=> fun void foo2;
> 1 => foo2; // prints 1
This is possible in SML. This can cause some unexpected code:
fun twice x = 2*x;
fun increment x = x + 1;
val twice = increment;
and now the function twice instead increments.
The code in Haskell is:
twice x = 2*x;
increment x = x + 1;
twice = increment;
and it produces this error in Hugs:
ERROR "Twice.hs":23 - "twice" multiply defined
even producing a joke. :-)
Haskell prohibits it because the renaming of functions seem dangerous
- it is not needed in programming, really.
Instead has a module system. In Haskell, it has to be in one file. One
module Twice (
<names to export (optional)>
Another file can then start with
This module can then define its own function twice. One will then have
to disambiguate between the two names Another.twice and Twice.twice.
More information about the chuck-users