Another question might be why the distinction between runtime and compiletime is important given JIT-compilation and optimizing virtualmachines?
BR
John
I was thinking that if there is no compiletime vs runtime dichotomy this would imply that dynamic dispatch is the only option for the language semantics, static dispatch can be an optimization strategy in the VM.
Is there a case for static dispatch besides optimization?
Br
John
Is to correct to say that the problems you describe are related to deterministic algorithms? If so, what is the current state of nondeteministic algorithms for this?
As Scala's subtyping is nominal, this is pretty easy to do:
class Foo {
def fun: String
}
class Bar {
def fun: String
}
def baz(x) = x.fun
There's no real way to disambiguate here within Scala's type system.
I was thinking of approaching inference as an optimization problem.
So instead of searching for the type for some term, the problem would in stead be to find the best type for it. Where all options would be valid combinations of fully inferred sub-terms and a set of ambiguity errors reported to the programmer. And best would be measured in some appropriate way like least amount of ambiguity, or mostly definitions requiring annotations or so.
Isn't that part of Paul Philips job description? :P
At this point, we're starting to get into territory that seems difficult to construct, and we haven't even looked at contravariance! (which is usually where the really undecidable questions arise)
It's my job to say it, and it'd nobody's job to listen!
Isn't this because the contravariant direction exposes the call-by-value (a.k.a. eager, strict) evaluation strategy language to infinite types in the universe (i.e. bottom), whereas covariance only exposes it to infinite possible values, i.e. top:
Isn't this because the contravariant direction exposes the call-by-value (a.k.a. eager, strict) evaluation strategy language to infinite types in the universe (i.e. bottom), whereas covariance only exposes it to infinite possible values, i.e. top:
No, it's because the distinction between co- and contravariance often makes it impossible to fix a most general type, since one is effectively comparing types along multiple axes. In the context of a nominal type system with subtyping and parametric polymorphism, contravariance also yields other, more interestingly undecidable questions.