On 2011-09-08 15:17, Steven Schveighoffer wrote:
You can if you make it a template parameter. For example, my openFile function that I wrote does this (in fact, I needed a template mode string because the return type depends on it). The downside is you cannot pass a runtime-generated string. I cannot actually think of any use cases for that however.In any case, the existing API does not use a template parameter, and we have to try and break as little code as possible. I wonder if there's a way to give the option of using a template parameter or using a positional parameter without having two different symbol names. hm... openFile!(string modedefault = "r")(string filename, string mode = modedefault) if (isValidOpenMode(modedefault)) { if(!isValidOpenMode(mode)) throw new Exception("invalid file open mode: " ~ mode); ... } Would that work? -Steve
That looks nice if it works. -- /Jacob Carlborg
