I was just wondering if anyone other than me thought that it would be incredibly usefull to have a language that was both dynamic AND statically typed.
Using Java as a example, it could do the following:
1) Define a special dot operator that auto type casted something of type Object to its lowest possible level. So maybe instead of ((Integer)getRandomTypeObject()).intValue()
, you could do getRandomObject()->intValue
. There ->
is the special operator. A function could take an Object
as its input and and just constantly use the ->
operator, which would make it dynamic.
2) Allow said operator to also "create" instance variables dynamically. So object->notCurrentlyExistantVariable = 2
would make a new variable called notCurrentlyExistantVariable
and set it to 2
, or else, if it does exist, just set its value.
3) Make everything an object so that the (1) suggestion would work for everything.
4) Make interfaces dynamic as well. So the compiler would just check if the object implements the functions of the interface, and would not care about its actually having the interface.
Is there a reason why this wouldn't be usefull. Methods where you KNOW what it's going to return you can use static types for clarity and for the IDE, but elsewhere you can use the Object
type with the ->
operator.