DMD 0.177 release
John Reimer
terminal.node at gmail.com
Mon Dec 11 16:10:17 PST 2006
On Mon, 11 Dec 2006 15:57:51 -0800, Sean Kelly <sean at f4.ca> wrote:
> John Reimer wrote:
>> From the perspective of setting initial state, classes in the OOP
>> context use constructors to do that. Structs were never intended to
>> have OOP like syntax (or so it seems to me). Why can't structs just
>> use an initializer like constants or statics? I notice that Walter has
>> added the struct initialization using S(x) syntax. I think it is
>> somewhat strange, but I suppose that was designed to be an alternative
>> to constructor initialization? What happened to something like a
>> struct literal intializer (which only works for static structs and
>> constant values)? Why can't such initialization be extended to local
>> structs?
>> ....
>> struct S
>> {
>> int i;
>> bool b;
>> }
>> static S t = { 5, true }; // must be "static" or initialization won't
>> work
>
> I think the problem here is that such initializers would not apply to
> private data, and more to the point, a ctor can do more than simply
> assign a constant to each member of the struct. But it would be nice if
> this syntax worked for non-static structs anyway.
>
Ah true. But then, maybe there shouldn't be private data in a struct
either. :)
I still see structs as a fairly basic non-OOP entity.
-JJR
More information about the Digitalmars-d-announce
mailing list