Is local variable type inference to be supported?

(noman) #1

I installed java 10 and noticed this new feature mentioned here:

It seems to be like the ‘auto’ feature in c++ where it is not dynamic typing but you still
do not have to “type the type” :yum: Anyway will I be able to use this feature using oxygene on cooper? Seems to be kinda cool.

(Friedrich Westermann) #2

It is part of the oxygene language since a long time I think

(marc hoffman) #3

I believe this has been supported since the very first Iodine version, using the var in lieu of the actual type name (ie same way C# did it). From a brief look at the link you posted, it seems official Java adopted the same syntax, so this should be call good (but I’ll make sure).

(noman) #4

I downloaded the java 8 and 10 language specifications in pdf and the var word does not exist in java 8. Here is a snippet from java 10: var is not a keyword, but rather an identifier with special meaning as the type of a local variable declaration (§14.4, §14.14.1, §14.14.2, §14.20.3).

Sorry to be late to reply but I did not get email notification of a reply to my post.

(marc hoffman) #5

Yes, same as in C#, and that’s how we implemented it for Iodine. var is not a keyword, but you can use in in places where you’d use a type name that can be inferred, ego cal var declarations.