On 12/14/2013 7:45 PM, logicchains wrote:
On Saturday, 14 December 2013 at 09:09:21 UTC, Rikki Cattermole wrote:
Personally for me its going a little far just having enum { with
multiple types being used as a value. But hey as long as everyone can
understand it, no problems!

I prefer untyped constants as they can be used as different types in
different places, like #define'd constants in C. If constants are too
strongly typed, it can lead to awkward situations such as in the Rust
code where two constants for the same value were used in order to avoid
a heap of ugly casts:
static StartRangei : u32 = 15;
static StartRangef : f64 = StartRangei as f64;

There's no such thing as an untyped constant in D. If you don't specify a type, it will auto infer the type of anything you assign it. If there's no value assigned, it defaults to int.

Reply via email to