views:

60

answers:

1

If I design a new language with type inference, no explicit types and no class inheritance support and then want to add inheritance, what are the minimum extra hints to the compiler needed to resolve type ambiguity when adding the feature?

Are class names needed?

EDIT

The type-tainting is traced through assignments throughout the program including between functions.

OK in the starting language, you have class names like MyTypeName1 from stuff like:

myVariable1 = New(MyTypeName1)
myVariable2 = New(MyTypeName2)

And types MyTypeName1 and MyTypeName2 are inferred for myVariable1 and myVariable2 respectively. But then if we want to enhance the language to support:

MyVariable3 = myVariable1
MyVariable3 = myVariable2

which can be traced through the code (myVariable3 now can contain two types which presumably are in a hierarchy).

EDIT

The members of MyTypeName1 and MyTypeName2 are inferred from statements like:

myVariable1.name="Fred"
myVariable2.name="JX3009"

What if the name member in MyTypeName1 and in MyTypeName2 are not to be in a common base class? What if we want a different name property in MyTypeName1 and MyTypeName2 and none in a base class? Is there an elegant way to tell the compiler what to do / how to handle? (The idea with type inference is to reduce typing not increase it...?)

Or do we need to specify the hierarchy explicitly?

+1  A: 
Norman Ramsey