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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 25 14:55:37 PDT 2012


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



--- Comment #15 from Stewart Gordon <smjg at iname.com> 2012-07-25 14:55:34 PDT ---
(In reply to comment #14)
> +1 from me. Implicit static and (worse) implicit enum are bad ideas, and the
> worst part is that whether it's static or not depends on whether there is an
> initializer or not.

I entirely agree.

> (admittedly I am left wondering what the difference is
> between "const int" and "immutable int", is it relevant?)

There isn't any real difference on the surface.  But when you take the address
of one, you get quite different types.

> However, as a compromise, perhaps if the user writes "const int x = 7;" the
> compiler could warn: "warning: since x is a constant, it should be declared
> with static or enum to avoid wasting memory."

How would the programmer suppress this warning because it's deliberate?

Maybe we need a new attribute for this.  This would also enable an immutable
value to be part of a struct's layout without breaking existing code.

-- 
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