I want to say that the type, value (if it is at compile time) and other information (I donβt know what I need right now) is the choice of expression.
For example, if I have an expression like
int i = unchecked((short)0xFF);
choosing 0xFF will give me (Int32, 255), while choosing ((short) 0xFF) will give me (Int16, 255), and I will give me choice (Int32, 255).
The reason I want such a function is to check my assumptions. It's pretty easy to assume that 0xFF is a byte, but it's actually int. Of course, I could constantly refer to the C # language specifications, but I find it inefficient to refer to it every time I want to check something. I could also use something like ANTLR, but the learning curve is high.
I am going to read all the specifications and learn about ANTLR and about compilers, but this is later. Now I want to have tools that will help me quickly and accurately complete the task.
Another example:
int? i = 0x10;
int? j = null;
int x;
x = (i >> 4) ?? -1;
x = (j >> 4) ?? -1;
This may seem easy or even natural for the bottom two lines in the code above. (Maybe code like this should be avoided, but this is another story). However, what msdn says about the null-coalescing operator , there is not enough information to tell me that the code above ((i β 4) ??) is legal (but it is). I had to delve into the grammar in the specifications to know what was going on:
- null coalescing expression
- or conditional expression
- conditional expression
- exclusive or expression
- and expression
- equality expression
- relational expression
- shear expression
- - additive-expression
... ( )
, , , . ( , , , , ) , . VS. , , .