templatizing parameters and induction (was Re: Writing Bug-Free C/D Code)
Andrei Alexandrescu (See Website For Email)
SeeWebsiteForEmail at erdani.org
Thu Mar 22 23:02:45 PDT 2007
David B. Held wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
>> [...]
>> int foo(int x, int y, int z);
>> int foo(static int x, int y, int z); // x is known during compilation
>> int foo(int x, static int y, int z); // y is known during compilation
>> int foo(static int x, static int y, int z); // x and y are... you know
>> [...]
>> final a = to!(int)(readln), b = to!(int)(readln);
>> foo(a, b, b); // firsts overload
>> foo(1, a + b, b); // 2nd
>> foo(a + b, a - b, b); // 3rd
>> foo(42, 7, b); // 4th
>> [...]
>
> Great sir, could you impart upon us mere mortals the wisdom by which you
> are able to ascertain, at compile time, the difference between two
> values known only at runtime (a la the "3rd" overload)? We are in great
> need of such Oracle-like behavior.
I also notice you're still posting from the future. You must make good
money daytrading. Future postulae commotus est. :o)
Andrei
More information about the Digitalmars-d
mailing list