Custom attributes (again)

Jacob Carlborg doob at me.com
Sat Apr 7 06:27:55 PDT 2012


On 2012-04-06 15:48, Adam D. Ruppe wrote:
> On Friday, 6 April 2012 at 12:52:27 UTC, Jacob Carlborg wrote:
>> Just as we have today with keywords and symbols, I don't see the problem.
>
> Things like safe aren't keywords though. They are just
> magic identifiers.
>
> Think of the implementation:
>
> switch(tok.ident) {
> case Id::safe:
> case Id::property:
> // etc for built ins
> default:
> // handle user ones here
> }
>
> If you were to define a struct safe {}, which is perfectly
> legal D, and try to use it, you won't get what you expect.
>
> It will trigger the case safe before it goes to the default.
> So, the user defined one will just be quietly hidden.

I mean that "int" is a keyword and "int" is in the same "scope" as the 
rest of the symbols. So if we allow custom attributes, like "@foo", it's 
the same "problem" as with regular identifiers. Regular identifiers can 
conflict with keywords.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list