The Sweet With

Walter Bright newshound1 at digitalmars.com
Tue Mar 3 10:50:37 PST 2009


Tomasz Sowiński wrote:
> Ideas for features based on the with.
> 
> The with can make calling functions with enum arguments sexier. So instead of:
> auto d = dirEntries(".", SpanMode.breadth);
> 
> you could say:
> auto d = dirEntries(".", breadth);
> 
> by declaring the function as:
> dirEntries(string path, with SpanMode mode);    // "with" does the trick

It looks nice, but has a subtle and disastrous problem. In D, arguments 
are fully resolved *before* overloading is done. If some of the 
overloads have with declarations, then there's a nightmarish problem of 
trying to mix overloading and argument resolution together.



More information about the Digitalmars-d mailing list