July 29, 2016
On Thursday, 28 July 2016 at 17:21:52 UTC, Sebastien Alaiwan wrote:
> On Thursday, 28 July 2016 at 06:21:06 UTC, Jonathan Marler wrote:
>> auto __DIR__(string fileFullPath = __FILE_FULL_PATH__) pure
>> {
>>     return fileFullPath.dirName;
>> }
>
> Doesn't work, I don't think you can wrap such things ( __FILE__ and such ):
>
> import std.stdio;
>
> int main()
> {
>   printNormal();
>   printWrapped();
>   return 0;
> }
>
> void printNormal(int line = __LINE__)
> {
>   writefln("%s", line);
> }
>
> void printWrapped(int line = __MY_LINE__)
> {
>   writefln("%s", line);
> }
>
> // wrapped version
> int __MY_LINE__(int line = __LINE__)
> {
>   return line;
> }
>
> $ rdmd demo.d
> 5
> 15  (should be 6!)
>
> Thus, the suggested implementation of __DIR__ would behave very differently from a builtin one. I'm not saying we need a builtin one, however, it might not be a good idea to name it this way.

Huh, interesting case, didn't think of that one.
1 2
Next ›   Last »