On Tuesday, 12 November 2013 at 08:50:29 UTC, Andrei Alexandrescu wrote:
One question would be whether the same work is needed for e.g. typeid() or toString. If not, maybe there is a case against factory.


That isn't the same. toString itself rely on typeid. And the typeid object is stored with the virtual function table. The code can retrieve that information for any object, even the ones that the code never heard about.

Object.factory require the inverse: finding the typeid from the name of the class. It require to build some structure that associate the name of a class and its typeid, and make it available for Object.factory.

I don't see how the existing system prevents you from rolling your own.


It doesn't, but I still need to pay for it.

The time difference is crucial here. If this DIP came up in 2006 (when I estimate we introduced Object.factory) probably a lot of things would have come down differently. Proposals made in different epochs are, I think, very difficult to compare.


I understand some design has been made for historical reasons. That happen to every system. That doesn't mean much.

Reply via email to