Feature request - type inference for new
Janice Caron
caron800 at googlemail.com
Mon Jun 16 10:23:19 PDT 2008
I've been quiet for a while. (Actually, I've been offline for a
while). So, I thought I'd better come back with a new feature request!
:-) Type inference for new. Here's an example:
class C(T)
{
Some!(Funky!(Class!(T))) funky;
this()
{
funky = new;
}
}
The type of funky is in the declaration, so why repeat it?
Another example...
class AnotherClassWithAVeryLongName
{
int x,y;
this(int x, int y) { this.x = x; this.y = y; }
}
void foo(int a, int b)
{
AnotherClassWithAVeryLongName c;
if (a < b) c = new(a,b);
else c = new(b,a);
}
Again, no need to repeat the type of c, because it's in the
declaration (this time a local declaration).
This will only work for assignments, because D doesn't overload on
return type. But still - I'm all for anything that saves typing.
More information about the Digitalmars-d
mailing list