Worst Phobos documentation evar!

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Sat Jan 3 21:32:05 PST 2015


"Manu via Digitalmars-d"  wrote in message 
news:mailman.4110.1420345278.9932.digitalmars-d at puremagic.com...

> >
> > template function(Arg)
> > {
> >     @uda(Arg) void function() { ... }
> > }
>
> Ah, interesting. I've never written a template function like that.
> Hmmm, is that how code is rewritten when compiling? If so, why doesn't
> it just work already?

I'm pretty sure you were told about this last time you asked about the same 
thing.

Yes, this is how the compiler re-writes function templates internally, but 
if you have udas:

@uda(Arg) void function(Arg)() { ... }

becomes

@uda(Arg) template function(Arg)
{
    void function() { ... }
}

This makes more sense when you remember that

@uda(Arg) void function(Arg)() { ... }

is identical to

@uda(Arg) { void function(Arg)() { ... } }

so it doesn't make a lot of sense to pull the UDA inside the template.

One weird thing is that it doesn't work with postfix udas either:

void function(Arg)() @uda(Arg) { ... }

Would that be appropriate for your code if it worked?  If so, it might be 
worth opening an enhancement.



More information about the Digitalmars-d mailing list