On Tuesday, 2 February 2016 at 14:36:05 UTC, Bambi wrote:
1. const isn't constant

The idea was to ease porting C code to D, so many things work the same in C and D except for maybe integer types that were borrowed from java.

The example snippet ' immutable(int[]) bar() immutable {} ' brings back bad memories of redundant declarations of the style ' Object object = new Object(); '.

Redundancy is not all that bad, but if you want less of it, you can: `auto bar() immutable {}` - the compiler will infer the return type.

2. when is an extern an extern?
The wiki page on interfacing with C states that C globals require an extra extern.

extern attribute is optimized for binding extern functions, which is what you need most of the time. In C you would need two attributes `extern cdecl` - one for extern and one for calling convention, in D it's done with one attribute, though it only specifies calling convention, because everything is implicitly extern anyway. It works well for functions, but not for variables, when you can't differentiate between declaration and definition.

3. typeof is an operator, sizeof is a property

sizeof is a property because it can work that way, and making it a whole special syntactical construct for this single purpose would be overkill. Now it can be implemented as a template, but it wasn't always this way.

Reply via email to