String literal arguments

bearophile bearophileHUGS at lycos.com
Wed Apr 7 01:31:53 PDT 2010


You have to take a look at what the compiler does normally. It doesn't do magic.

Generally a function is something that takes a run-time value with a simple protocol. So when an argument is inside a function, it's a variable, even if the function was called with a constant.

Walter actually tried to implement what you ask for, the static arguments for functions (or better the enum arguments, in my opinion), but he has given up because it's not easy to implement. So currently you have to write:
foo!("Hello World")(first, second);
Or:
foo!"Hello World"(first, second);

This tells the compiler to partially compile foo according to the first argument as a complile time constant, and according to two the run time variables.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list