Type properties
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jan 7 06:30:04 PST 2016
On 1/6/16 3:01 AM, ric maicle wrote:
> Why is init allowed to be redefined but not sizeof?
>
> dmd 2.069
>
> import std.stdio;
>
> struct Foo {
> static int init = 5;
> static int sizeof = 0;
> }
>
> void main()
> {
> writeln(Foo.init);
> writeln(Foo.sizeof);
> }
>
> Error: variable integer.Foo.sizeof .sizeof property cannot be redefined
At the moment, we need this. The TypeInfo member that contains the
initialization data was called init. It was very recently switched to
initializer, but we cannot get rid of that alias for a few releases.
After that, I think we can consider removing that ability from the language.
One thing that just occurred to me though, Objective-C makes use of the
init function quite a bit. I wonder how getting rid of init as a
customizable member would affect that.
-Steve
More information about the Digitalmars-d-learn
mailing list