[nem-en] Can local functions be polymorphic (generic)?
Michal Moskal
michal.moskal at gmail.com
Mon Feb 19 16:41:08 CET 2007
On 2/19/07, Vladimir Reshetnikov <v.reshetnikov at gmail.com> wrote:
> Why local function signature cannot contain ref/out modifiers?
> Just to simplify type inference?
Not really type inference. The problem is that we represent function
types as generic interfeces and you cannot pass ref/out types as
generic type parameters. Therefore such functions couldn't be used in
first class scenarios, which means you cannot write something like the
following:
foo (fn : ref int -> void) : void
{
mutable x = 7;
fn (ref x)
}
Disallowing this in other local functions (that are not used as first
class) might be a bit too restrictive, but at least the rule is
simple. Allowing it would probably mean some implementation work here
and there.
--
Michał
More information about the devel-en
mailing list