[Issue 4551] D2 Language Docs: http://www.digitalmars.com/d/2.0/arrays.html
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jan 28 06:32:12 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4551
Denis Derman <denis.spir at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |denis.spir at gmail.com
--- Comment #5 from Denis Derman <denis.spir at gmail.com> 2011-01-28 06:30:00 PST ---
(In reply to comment #1)
> > "Static Initialization of Static Arrays"
> >
> > The documentation states:
> > "These arrays are static when they appear in global scope. Otherwise, they need
> > to be marked with const or static storage classes to make them static arrays."
> >
> > In non-global scope, I can only compile if the array is marked with static or
> > static const.
> >
> > const alone will not compile for me:
> >
> > enum Color { red, blue, green };
> >
> > void main() {
> > const int value[Color.max + 1] = [ Color.blue:6, Color.green:2, Color.red:5
> > ];
> > }
> >
> > test2.d(192): Error: Integer constant expression expected instead of Color.blue
> > test2.d(192): Error: Integer constant expression expected instead of
> > Color.green
> > test2.d(192): Error: Integer constant expression expected instead of Color.red
> > test2.d(192): Error: Integer constant expression expected instead of Color.blue
> > test2.d(192): Error: Integer constant expression expected instead of
> > Color.green
> > test2.d(192): Error: Integer constant expression expected instead of Color.red
>
> I'm not sure what was meant here by Walter. I suspect that "Static array"
> should be changed to "fixed sized array" everywhere, but that's a huge change,
> that I'm not comfortable making. I think the text is meant to say that in
> order to make an array a "static variable" (i.e. keeps its value across
> function calls) you have to apply the static attribute.
Actually, what is "static" (in the D sense of predefined, knwon at
compile-time), is the *size*, and only the size. So, the proper (again using
D's sense of "static") term could be "static-size array".
Note that in english "static" and "dynamic" 's first senses are "that cannot
change" and "that can change". This is really not what those words mean in D
and similar languages. "static" and "dynamic" are used in D to mean what in
math is called "constant" (predefined) and "variable" (defined at application
time). Lol!
Denis
--
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