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

Wolfgang Draxinger wdraxinger at darkstargames.de
Tue Jul 25 05:15:19 PDT 2006


Oskar Linde wrote:

> Another proposal that I made before in conjunction with the
> above is to make implicit template properties explicit via the
> /this/ keyword. It would work analogous to how /this/ is used
> to denote class constructors.

I like that, and it would be just logical.

Also I don't see a reason, why the multifunction template
proposal would break existing code, if adding some rules: If
such a template is instanciated "annonymously" and not used in
an assignment, the local scope should be implicitly considerd
the the L value of a "silent" assignment.

Example

template foo(T) {
        int foo(T){...}
        T foo(int){...}
}

foo!(bool);
foo!(float) bar;
auto fbr = foo!(char[]);
auto bfo = foo!(void*);

// typeof(foo(true))==int;
// typeof(foo(1))==bool;

// typeof(bar.foo(false))==int;
// typeof(bar.foo(0))==float;

// typeof(fbr.foo(""))==int;
// typeof(fbr.foo(2))==char[];

// typeof(bfp.foo(NULL))==int;
// typeof(bfp.foo(3))==void*;

However I'm not sure if that would be context free, but I think
it probably is.

Wolfgang Draxinger
-- 
E-Mail address works, Jabber: hexarith at jabber.org, ICQ: 134682867
GPG key FP: 2FC8 319E C7D7 1ADC 0408 65C6 05F5 A645 1FD3 BD3E



More information about the Digitalmars-d mailing list