[Issue 3449] const and invariant struct members do not behave according to spec

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 23 05:16:08 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=3449



--- Comment #12 from Stewart Gordon <smjg at iname.com> 2012-01-23 05:16:02 PST ---
(In reply to comment #11)
> I think that  the *implicit static* variable is the worst 
> specification in D.  'const/immutable(not modifiable)' and 
> 'static(not per-instance)' is definitely orthogonal concepts, but 
> in your argument, they are scary mixed.

Agreed.  Half the point of structs is that the layout in memory can be
guaranteed.  Being able to include immutable values within this memory layout
(such as struct size in the case of some Windows API structs, or file format
signatures) should be part of this.

In classes, where there is no guarantee of memory layout, it makes sense to
optimise immutable members to be static.  In structs, OTOH, const/immutable
should do what it says and nothing more.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list