Is this a bug or feature?
BCS
ao at pathlink.com
Tue Jan 16 17:08:48 PST 2007
Reply to Kirk,
> BCS wrote:
>
> Method literals, eh? Nifty.
>
Not just methods:
int[] foo;
(&foo).{
int ret = 0;
foreach(int i; *this) ret += i;
return ret;
}
maybe even anything that can fit int a size_t (byte, short, int)
Why not interface literals?
interface I { int foo(); }
struct S { int i; }
auto a = new S;
I i = s.I // I don't like the syntax, but...
{
int foo()
{
return this.i;
}
}
Of course this requiters that interfaces be re implemented using context/v-table
pairs, but that is an old soap-box.
More information about the Digitalmars-d-learn
mailing list