Miller, Hugh wrote:
What about the type support (system) one sees in ML ? (e.g., the way it
assigns automatically types can be assigned, does not require specific
types when they are not needed, flags incompatibilities, etc.) Do those
things not fit well with Perl's approaches and aims ?
They don't really fit with Perl 6 too well. For example, suppose we tried to type inference this:

my $a = 42;
foo();
my $b = $a;

What is the type of $b? Well, we can't actually infer that because foo might be:

sub foo() {
   $OUTER::a = "oh hi, i iz not int!"
}

And because subs can be wrapped at runtime, or symbol tables can be diddled, or other such fun, we probably can't safely look at foo at compile time in the general case to make sure our inference is correct too, because foo might not be the foo we thought it was at compile time by the time we reach runtime.

From what I can see, making a language where the types are inferable, like ML, can almost involve doing the language design on a knife edge. You need the inference to not only be decidable, but also reasonably efficient, and a subtle feature interaction can hurt this (I think ML nearly had one of these when ref types and let statements interacted in a way that could compromise type safety - I'm rusty on the details). And if I'm remembering correct, there are contrived programs you can write that make the ML checker go exponential order in the size of the code too.

Jonathan

Reply via email to