custom attribute proposal (yeah, another one)

bls bizprac at orange.fr
Fri Apr 6 10:51:28 PDT 2012


On 04/06/2012 07:04 AM, Manu wrote:
> I think Johannes proposal already nails it. What benefits would be
> merged from this proposal? How would they influence the design?
>
>     On 04/06/2012 11:41 AM, Johannes Pfau wrote:
>
>         Declaring a custom attribute:
>         ---------
>         module std.something;
>
>         struct Author
>         {
>             string name;
>             public this(string name)
>             {
>         this.name <http://this.name> = name;
>             }
>         }
>         ---------

Why not being more flexible .. Likewise

struct Annotation  //Throw in all your annotations
{

	Variant[] [string] map;

	Variant[] opDispatch(string key)()
	{
        		return map[key];
     	}	
	
	// Single value
	Variant[] opDispatch(string key, T) (T t )
	if ( !isArray!T && !isTuple!T )
	{
		index ~= key;
		map[key] ~= to!Variant(t);
		return map[key];
	}	
	....Array, Tuple	
}
well.. I am not sure about CTFE


More information about the Digitalmars-d mailing list