May 09, 2013
On Friday, 26 April 2013 at 16:13:44 UTC, Luís Marques wrote:
> BTW, I was working on a Object.factory scenario right now (!) and stumbled on the limitation that the class can only have a default constructor. Couldn't you call a non-default constructor by passing var args to Object.factory()?

In the docs,

"The class must either have no constructors or have a default constructor."

I thought that meant that the class must have either no constructors at all, or if it does have constructors there must be a default constructor. That is not that same as stating that it must have only a default constructor, correct?

May 09, 2013
On Thursday, May 09, 2013 20:55:43 Rob T wrote:
> On Friday, 26 April 2013 at 16:13:44 UTC, Luís Marques wrote:
> > BTW, I was working on a Object.factory scenario right now (!) and stumbled on the limitation that the class can only have a default constructor. Couldn't you call a non-default constructor by passing var args to Object.factory()?
> 
> In the docs,
> 
> "The class must either have no constructors or have a default constructor."
> 
> I thought that meant that the class must have either no constructors at all, or if it does have constructors there must be a default constructor. That is not that same as stating that it must have only a default constructor, correct?

If a class doesn't have any constructors, then a default constructor is provided.

- Jonathan M Davis
May 30, 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

?
1 2
Next ›   Last »