Why the @ in @safe? & UDAs

Jacob Carlborg doob at me.com
Thu Nov 7 12:58:50 PST 2013


On 2013-11-07 17:24, Dicebot wrote:

> P.S. There was a mention that introduction of UDA's has made addition of
> new @-prefixed built-ins impossible without breakage. It is not entirely
> true as symbols used in UDA's are qualified and conform to normal symbol
> lookup rules. Only problem is that built-in stuff is pure magic and has
> no own module.

That only works if you always use fully qualified names for your UDA's:

enum foo;

@foo void bar () { }

Keyword "@foo" is introduced. Now you have a code breakage. Sure, it's 
an easy fix and you can keep the name of your UDA, but you still need to 
change every place where it's used.

Actually, I don't know what will happen if a keyword is introduce that 
has the same name as your top level package.

module top.level.pack;

enum foo;

module bar;

import top.level.pack;

@top.level.pack.foo void bar () { }

What happens if "@top" is introduced as a keyword?

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list