Contextualizing keywords

Max Samukha spambox at d-coding.com
Mon Aug 3 06:28:43 PDT 2009


On Mon, 03 Aug 2009 09:10:49 -0300, Ary Borenszweig
<ary at esperanto.org.ar> wrote:

>Max Samukha escribi?:
>> On Mon, 03 Aug 2009 01:41:53 -0500, Andrei Alexandrescu
>> <SeeWebsiteForEmail at erdani.org> wrote:
>> 
>>> Robert Fraser wrote:
>>>> Walter Bright wrote:
>>>>> Oliver Hoog wrote:
>>>>>> Robert Fraser schrieb:
>>>>>>> Chad J wrote:
>>>>>>>> This makes things more difficult for syntax highlighters.  A number of
>>>>>>>> them will just not work correctly because they don't actually parse 
>>>>>>>> the
>>>>>>>> code.
>>>>>>>> That's all I've got.
>>>>>>> Ehhh.... How often will you actually use the identifiers? The point 
>>>>>>> isn't to make them free for use, it's more to reduce the number of 
>>>>>>> people bitching about how many keywords there are.
>>>>>> I guess they would still keep complaining since the number of 
>>>>>> available keywords to be remembered doesn't decrease.
>>>>> There are a million words in the English language, so it's not likely 
>>>>> that we'll run short of identifier space in the conceivable future :-)
>>>>>
>>>>> The real problem is remembering the keywords.
>>>> Eh? I disagree -- think about how many uses of "static" there are, or 
>>>> the wars about "enum". Overloading keywords is MUCH more confusing than 
>>>> reserving another word.
>>> Confession:
>>>
>>> I've never, ever been confused by the use of "static". Not even once, 
>>> and not even when I was a complete beginner. I have always taken in the 
>>> numerous jokes related to "static" with the politely faked, resigned 
>>> smile of someone who knows will never really "get" it. And deep in my 
>>> heart of hearts, whenever a "static" joke comes about, the belief that 
>>> I'm an outcast sinks in a bit deeper.
>>>
>>> Guess it's time for me to join the Static-Impaired Anonymous...
>>>
>>>
>>> Andrei
>> 
>> I dare say I don't believe you. What about static (aka fixed-size)
>> arrays that can be allocated non-statically on stack or statically in
>> the static data segment? So we have static static arrays and static
>> non-static arrays. If it's not a confusion, I don't know what it is.
>> 
>> The D specs at
>> http://www.digitalmars.com/d/2.0/arrays.html#static-arrays continue
>> the tradition. Please read "Static Initialization of Static Arrays".
>> The section confusingly claims that static arrays are not static when
>> they appear in a local context without 'static' modifier.
>
>What does that mean? I don't get it...

void foo()
{
    int[4] a; // static (fixed-size, not dynamic) array
    static int[4] b; // static (allocated in the static data segment)
and static (fixed-size) array;  
}

Here we have two absolutely unrelated concepts denoted by 'static':
1. Having a length fixed at compile time
2. Allocated in the data segment

When they are shoved together, they make things confusing, just like
in "Static Initialization of Static Arrays" where the second 'static'
in the title refers to either 1 or 2, or both, but not to the static
arrays allocated on stack, while 'static' in the title and contents of
"Static Arrays" section refers to 1 and covers all static arrays
including those allocated on stack.







More information about the Digitalmars-d mailing list