Search code examples
c#language-design

Better word for inferring variables other than var


This might get closed, but I'll try anyway.

I was showing a VB6 programmer some of my C# code the other day and he noticed the var keyword and was like "Oh a variant type, that's not really strong typing when you do that." and I had to go on the typical "var != VARIANT" speech to explain to him that it is not a variant it just compiler inferred.

I was thinking about other words they (C# team) could have used so this kind of thing didn't happen. I personally like infer, something like:

 infer person = new Person("Bob");

I know this is not really that big of deal, but just curious to see what other people would use to do the same thing.

I have made this a community wiki because it doesn't really have an answer.


Solution

  • C++0x uses the "auto" keyword for type inference:

    http://en.wikipedia.org/wiki/C%2B%2B0x#Type_inference

    That's not a bad trade-off for those guys since "auto" was (AFAIK) already a keyword. I can imagine it in C#:

    auto i = 3;
    

    I do like "infer" though (but then I don't have any problem with "var" either).