Inferring the Type in C++,C#, VB Code On Compilation

  • Thread starter Thread starter Taher Hassan
  • Start date Start date
T

Taher Hassan

Guest
Hi there, this is just a discussion point and suggestion for the Microsoft Development Community's kind consideration. I was looking into the use of the var keyword in C# in LINQ where it is used for an inferred type which the compiler actually infers at compile time. I'm not sure about the use of the var keyword as I think this may be a bit confusing. I was thinking that the user could leave out the var keyword altogether and the Visual Studio compiler could put in the full type name at compilation. For anonymous types the LINQ query could use an "as" clause (just like SQL) where the type name that the user wanted to create could be given and then could be put in in the code by the compiler.

This inferring of an omitted type and insertion into the code could be done for all statements requiring a type specifier eg myVariable=3 becomes after compilation becomes int myVariable=3.

This way the advantages of inferring the type could be used whilst keeping the code as readable as possible. What do you think please ?

Continue reading...
 
Back
Top