Extend the call site default argument expansion mechanism?

Dukc ajieskola at gmail.com
Fri May 11 11:42:07 UTC 2018


On Thursday, 10 May 2018 at 14:15:18 UTC, Yuxuan Shui wrote:
> ...
> // constructor of DataStructure
> this(Allocator alloc=__ALLOC__) {...}
> ...
> auto alloc = new SomeAllocator();
> define __ALLOC__ = alloc;
> // And we don't need to pass alloc everytime
> ...
>
> Is this a good idea?

Doesn't this basically mean including the implicits Martin 
Odersky talked about at Dconf in D?

I don't know whether it's a good idea all-in-all, but assuming 
the arguments can be used as compile-time I can already see a big 
use case: killing autodecoding without breaking code. Something 
like:

auto front(C, bool disableDecoding = __NODECODE__)(inout C[] 
string)
{   static if (disableDecoding) {...}
     else {...}
}


More information about the Digitalmars-d mailing list