All about types
Posted: Sun Jul 26, 2009 6:42 pm
So on IRC this has come up a few times (correction: I brought it up a few times to change the tide ), and it is possible that I am the only one that feels this way. With that said I am particular (slightly persnickety) about the way my types are named (probably Scala syndrome). Anyway, as you may know in C# the following both do the same thing...
Int32 is a member of the System namespace, fully qualified as System.Int32, and int is simply an alias to this structure. My point of view is that types are nouns-- we name user-defined types as nouns (the type of real world objects)--and as such should be named accordingly for consistency. I am in favor of Single, Double, Decimal, Dynamic, Int, Byte, etc. over float, decimal, int8, etc.
I like the pascal-cased versions for the following reasons:
In the more general sense there are multiple languages running on .NET/Mono (as they were designed to accommodate), and by keeping the "primitive" types in sync with the underlying types (provided by the CTS) makes libraries more "transferable". The word transferable is used here in the sense that Boo, C#, and VB users can look at Cobra code and implicitly absorb the types.
Just trying to get a feel for what the rest of the community feels regarding this. I'm possibly very off-base on the issue.
- Code: Select all
int a = 1;
Int32 a = 1;
// cobra can provide Int and Bool in place of Int32 and Boolean for conciseness
Console.WriteLine(a.GetType()); // produces System.Int32
Int32 is a member of the System namespace, fully qualified as System.Int32, and int is simply an alias to this structure. My point of view is that types are nouns-- we name user-defined types as nouns (the type of real world objects)--and as such should be named accordingly for consistency. I am in favor of Single, Double, Decimal, Dynamic, Int, Byte, etc. over float, decimal, int8, etc.
I like the pascal-cased versions for the following reasons:
- The common type system (CTS) types makes anyone familiar with .NET or Mono know immediately what a type truly stands for
- They are a type and are named like any other type users may define
- They are consistent with System.Type, so 5.getType will be Int32 and so on
In the more general sense there are multiple languages running on .NET/Mono (as they were designed to accommodate), and by keeping the "primitive" types in sync with the underlying types (provided by the CTS) makes libraries more "transferable". The word transferable is used here in the sense that Boo, C#, and VB users can look at Cobra code and implicitly absorb the types.
Just trying to get a feel for what the rest of the community feels regarding this. I'm possibly very off-base on the issue.