UDAs - Restrict to User Defined Types?

David Nadlinger see at klickverbot.at
Wed Nov 7 16:03:57 PST 2012


On Wednesday, 7 November 2012 at 23:18:41 UTC, Walter Bright 
wrote:
> One last thing. Sure, string attributes can (and surely would 
> be) used for different purposes in different libraries. The 
> presumption is that this would cause a conflict. But would it? 
> There are two aspects to a UDA - the attribute itself, and the 
> symbol it is attached to. In order to get the UDA for a symbol, 
> one has to look up the symbol. There isn't a global repository 
> of symbols in D. You'd have to say "I want to look in module X 
> for symbols." Why would you look in module X for an attribute 
> that you have no reason to believe applies to symbols from X? 
> How would an attribute for module X's symbols leak out of X on 
> their own?

Wasn't the @every_body_writes_their_names_like_this in C earlier 
in this thread yours? The problem is that without resorting to 
some kind of »unique« prefix convention, there will inevitably 
be modules X and Y which use the same annotation string for 
different purposes, creating problems if both modules are used 
together in the same code base (think passing a symbol from X to 
a template in Y, or an user wanting to create a type which is 
passed to both X and Y).

I feel this is of particular significance here, as I think 
attributes are primarily going to be used in this kind of library 
context, where you allow the library user to mark their symbols 
up in a way that effects your library's behavior on said symbols.

David


More information about the Digitalmars-d mailing list