namespace Cobra.Lang
extend System.Object
def typeOf as System.Type
""" Using.typeOf is portable between platforms in contrast to CLI .getType and JVM .getClass. """
return .getType
You'll still be free to write VM-specific code such as obj.getType on .NET and obj.getClass on JVM. But .typeOf will be available for making code more portable and you'll see it in samples, how-to's and tests.
I chose the name because other names like "type" and "getType" are too common on one platform or the other. "typeOf" is hardly used. I determined this using Google Code Search with lang:C# and lang:Java.
In the rare event that you had a library class with a .typeOf method, saying "foo.typeOf" would invoke that specific method since it would be found before the extension on Object. If you needed to get to the Object one, you could typecast with "(foo to Object).typeOf". Of course, if the library's .typeOf method took arguments then method overloading would kick in and you wouldn't need any typecasts at all.
Feedback and questions are welcome.