Object.factory() and module name

eles eles at eles.com
Thu May 30 00:59:07 PDT 2013


On Friday, 26 April 2013 at 15:52:02 UTC, Justin Whear wrote:
> On Fri, 26 Apr 2013 17:36:31 +0200, eles wrote:
>
>> On Friday, 26 April 2013 at 15:34:01 UTC, eles wrote:
>
>    Object.factory(__MODULE__ ~ ".Human");

I revive this wrt to the 2.063 release, where the __MODULE__ was 
added.

The question that I have now is rather philosophical:

The __MODULE__ is described as a "special identifier" that is 
"useful in debugging code" (see the 2.063 changelog, by the way, 
a masterpiece of changelogs, congratulations for that).

So... is that OK, philosophically, to use "debug" identifiers to 
write something that is more like "templated" code? (the original 
question was about the automatically providing the module's name 
in the Object.factory() method). Unlike __LINE__, __MODULE__ is 
somewhere between the lines.

Yes, now it works like that:

Object.factory(__MODULE__ ~ ".Human");

But is that the recommended way to do it? Should we still aim for:

Object.factory(".Human"); //if module name is not specified, the 
current module is assumed

?


More information about the Digitalmars-d mailing list