Either I'm just too stupid, or D is lacking something

Oskar Linde oskar.lindeREM at OVEgmail.com
Tue Jul 25 03:58:21 PDT 2006


Wolfgang Draxinger skrev:
> Oskar Linde wrote:
> 
>> It is a minor change, but would break existing code, so getting
>> it before 1.0 would be preferred.
> 
> Could you give me an example of breakage? I don't see a reason
> (yet), why that would break something. I'd have said, that my
> suggestion is a superset of the old behaviour and backwards
> compatible, but seem's I was wrong.

Currently, when a template contains several functions, they are not 
implicit template properties and must be called as func!().func(...). If 
the proposed change was introduced, they would be required to be called 
as func!()(...). Example:

struct Foo { int foo; }

template foo() {
	Foo foo() { Foo r; return r; }
	Foo foo(int x) { Foo r; return r; }
}

void main() {
	auto x = foo!().foo;
	// with current behavior, typeof(x) == Foo,
	// with proposed behavior, typeof(x) == int.
}

I still think the change is worthwhile.

/Oskar



More information about the Digitalmars-d mailing list