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
At first glance, such feature seems lesser. But I noticed that for fear of
redundancy programmers resort to cluttering the global scope with constants, or
even worse - using bool to offer only two options. So when the API needs an
equivalent of GUI's dropdown list, the with encourages the right way - enums.
The with can also tidy up numerous imports:
import extremely.long.package.name.module1;
import extremely.long.package.name.module2;
import extremely.long.package.name.module3;
import renamed = extremely.long.package.name.module4;
import extremely.long.package.name.module5 : selective;
...
could be compressed to:
import with (extremely.long.package.name)
{
module1;
module2;
module3;
renamed = module4;
module5 : selective;
...
}
or even:
import with (extremely.long.package.name)
module1, module2, module3, renamed = module4, module5 : selective, ... ;
What do you say?
Tomek

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.

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.

What about the feature you mentioned at the D con, about being able to
use enums without the enum name? Or will/would that only be for
things where it's really obvious, like switch statements?

Unless that was only for things like switch statements, I would hate that.
I've used enums in languages that worked that way, and I found it to be such
a problematic namespace-clutterer that in those languages I always hack up
my enum definitions like this:
enum Color
{
Color_Red,
Color_Blue,
Color_Orange,
// etc...
}
Which is a style that I've always considered an ugly and kludgey, but
unfortunately necessary, substitute for manditory enum names.

Ideas for features based on the with.
The with can make calling functions with enum arguments sexier. So
instead
of:
auto d =3D dirEntries(".", SpanMode.breadth);
you could say:
auto d =3D 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, argument=

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.

What about the feature you mentioned at the D con, about being able to
use enums without the enum name? =A0Or will/would that only be for
things where it's really obvious, like switch statements?

Unless that was only for things like switch statements, I would hate that=

I've used enums in languages that worked that way, and I found it to be s=

a problematic namespace-clutterer that in those languages I always hack u=

Oh, the way he described it in the slides was different. As in,
normally you would use Color.Red, but inside a switch:
switch(widgetColor)
{
case Red: // this is *completely* unambiguous
}
And such. Red is not a global; it's rather that name lookup is
changed for some constructs.