pure, safe and generalized attributes

Janice Caron caron800 at googlemail.com
Sat Apr 5 09:57:39 PDT 2008


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.



More information about the Digitalmars-d mailing list