handful and interval
bearophile
bearophileHUGS at lycos.com
Mon Sep 3 08:05:45 PDT 2012
David Nadlinger:
> Where would the real difference to ["struct", "class",
> "union"].canFind(a) then? A sufficiently smart compiler (tm)
> could optimize this to a efficient string "prefix switch
> statement" just as well…
I think a smart compiler is not needed.
Maybe a general solution is to introduce a way to define
overloaded templates callable as functions, that get called if
the input is a literal (or statically known, but D design
requires you to asks explicitly for a CT evaluation):
void foo(static int[] a) {}
void foo(int[] a) {}
void main(string[] args) {
foo([1, 2]); // calls first foo
int[] a = [1, 2] ~ args.length;
foo(a); // calls second foo
}
Bye,
bearophile
More information about the Digitalmars-d
mailing list