www.digitalmars.com         C & C++   DMDScript    digitalmars.D
- Re: Enum arguments?  Sorry for pulling out this old thread
again, I have one thing to add.   void convolve(const float[][]
mat, enum float[][] mask, float[][] outmat);  A possible variant
of "enum" arguments is "auto enum" arguments. If the given value
is a compile-time constant then the function becomes a template
as before. Otherwise if the given value is a run-time value,
then the argument is a normal function argument. So this code:
void foo(int a, auto enum int b) {} void main() { int x = 10;
enum int y = 10; foo(x, y); int z = 10; foo(x, z); } is syntax
sugar for: void foo_t(int b)(int a) {} void foo(int a, int b) {}
void main() { int x = 10; enum int y = 10; foo_t!(y)(x); int z =
10; foo(x, z); } This allows for a cheap form of partial
compilation :-) It's "cheap" for the compiler because it's the
programmer that tells the compiler on what it can partially
compile, so the compiler doesn't need to be smart to guess as in
a true partial c