pure, safe and generalized attributes
Knud Soerensen
4tuu4k002 at sneakemail.com
Sat Apr 5 13:11:32 PDT 2008
Janice Caron wrote:
> On 05/04/2008, Knud Soerensen <4tuu4k002 at sneakemail.com> wrote:
>> Janice Caron wrote:
>>
>>> On 05/04/2008, Knud Soerensen <4tuu4k002 at sneakemail.com> wrote:
>> >> You could also ague that it is not necessary because
>> >> attributes can only appear in certain places
>> >>
>> >> only in function, class, struct and module declarations.
>> >
>>
>>> KilroyWasHere:
>> >
>> > Is that an attribute or a label?
>>
>> "KilroyWasHere" is the label for the attribute
>> that this place was inspected by Kilroy
>>
>> Why do you ask ??
>
> I was trying to make the point that D has a context-free grammar, and
> that an identifier followed by a colon, where you might expect to find
> a statement or a declaration, might be ambiguous.
>
> In hindsight, I might have jumped too fast. It might be possible to
> tell the difference because: if you're expecting a statement, it's a
> label; if you're expecting a declaration, it's an attribute.
>
> However, the point still stands. Allowing arbitrary identifiers as
> attributes is /bound/ to confuse the parser somewhere along the line,
> unless we explicitly indicate to the compiler that this identifier is
> an attribute.
I see that the D manual already have something called attributes
it might have been confusing you.
Maybe if i use the word constrain, for what we talking about is a way to
define code constrains.
We have this now i D
ModuleDeclaration:
module ModuleName ;
ClassDeclaration:
class Identifier BaseClassList(opt) ClassBody
FunctionDeclaration: (I didn't find this in the manual)
type Identifier(Parameters) FunctionBody
With constrains we will have this
ModuleDeclaration:
module ModuleName ConstrainList(opt);
ClassDeclaration:
class Identifier BaseClassList(opt) ConstrainList(opt) ClassBody
FunctionDeclaration:
type Identifier(Parameters) ConstrainList(opt) FunctionBody
Hope this helps
Knud
More information about the Digitalmars-d
mailing list