News for hackers. Stuff that matters.
Re:The Ergonomics of Type Checking (2016) by hliyan on Saturday October 28, 2017 @03:10PM (#15576332)
It will need to be a language without method overloading.
Re:The Ergonomics of Type Checking (2016) by emodendroket on Saturday October 28, 2017 @03:48PM (#15576495)
So no two classes anywhere in the entire project can have a method with the same signature?
Re:The Ergonomics of Type Checking (2016) by gizmo686 on Saturday October 28, 2017 @04:26PM (#15576620)
No, they just cant have the same name if they are in the same namespace.

Even languages with overloading dont allow them in the same namespace if they also have the same signature.

Re:The Ergonomics of Type Checking (2016) by emodendroket on Saturday October 28, 2017 @06:39PM (#15577044)
How does this hypothetical compiler know whether to take NamespaceA.Queue.Size or NamespaceB.DynamicArray.Size or NamespaceC.File.Size?
Re:The Ergonomics of Type Checking (2016) by gizmo686 on Saturday October 28, 2017 @11:43PM (#15577868)
Because a compiler will only load symbols from the current namespace. If you import both Queue.Size and DynamicArray.Size, then try to call Size, the compiler may fail due to the ambiguous reference to "Size". If you wanted access to both of them in the same namespace, you would have to do some form of a qualified import/reference to disambiguate for the compiler. This is the way that any language that does not support overloading handles this, regardless of type system.

It is also possible for the compiler to use type information to attempt to disambiguate. Especially because this would normally happen across module boundaries, a hypothetical compiler could:

1) Infer types based on all non-ambiguous references (or all references within the compilation unit that contains the definition)

2) Disambiguate all ambiguous reference using type information.

I suppose a sufficiently smart compiler could attempt to do type inference and disambiguation at the same time; but that sounds like introducing NP hard problems to the compiler for the sole purpose of allowing confusing code.