Extended Type Design.
Kevin Bealer
kevinbealer at gmail.com
Wed Mar 21 22:22:30 PDT 2007
Bill Baxter wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
>> Bill Baxter wrote:
>>> Andrei Alexandrescu (See Website For Email) wrote:
>>>> sclytrack wrote:
>>>>>> IMHO (b) should be 'readonly' and (c) should be 'const'.
>>>>> [snip]
>>>>>
>>>>> vote++
>>>>>
>>>>>
>>>>> Keywords
>>>>> --------
>>>>>
>>>>> I also think keywords can be written attached to one another.
>>>>> Like if you were to really call it "super const" have it called
>>>>> superconst instead of super_const.
>>>>
>>>> Yet you write static const not staticconst; public static not
>>>> publicstatic; static if and not staticif; and so on.
>>>>
>>>> superconst came up too. But it creates a bad precedent. A healthier
>>>> precedent is to synthesize phrases, not new keywords, from the
>>>> existing keywords. Think of "static if" or "final switch". Very
>>>> beautiful.
>>>>
>>>>> It is like the foreach_reverse that we have in D. Why not
>>>>> call it foreachreverse instead.
>>>>
>>>> Probably it's best to call it foreach reverse. It's unambiguous,
>>>> easy to parse, does not add new keywords, and continues another nice
>>>> precedent set by extern(language) and by scope(exit).
>>>
>>> So you mean foreach(reverse) then? I do like that! You're right
>>> that it is quite D-like. Too bad you weren't around back when
>>> foreach_reverse was introduced? ;-)
>>
>> Possibly even without the parens:
>>
>> foreach (i ; array) { ... }
>>
>> foreach reverse (i ; array) { ... }
>>
>> I have a feeling Walter is unlikely to change that though :o).
>>
>>
>> Andrei
>
> Except then 'reverse' would have to be a keyword too, no?
I think the theory is that, like scope(exit), where the 'exit' is not
really a keyword, in the foreach xyz (...) {...} expression, there is no
legal token that can go where 'xyz' is, so something there doesn't need
to be special. You could use "i" or "main" without conflicting with a
variable or function name, for instance, because those can't appear there.
It's only in places where a user-defined identifier is legal that a
given 'adjective' word needs to be keywords. You could define this:
if and only if () {} while away the hours () {}
... and not conflict with existing variables named (and, only, away,
the, hours).
Kevin
>
> --bb
More information about the Digitalmars-d
mailing list