On Tuesday, 12 November 2013 at 22:45:15 UTC, Andrei Alexandrescu
wrote:
What are the better ways? Note that most of the time you don't
"know" the name of a class - you get it down the wire during
some deserialization. So there must be some way to build an
object from a token representation of the object.
The serialization is a good example. You'll have to note that if
the code has been able to serialize the data, it can generate at
compile time the necessary scafolding to deserialize it.
- The functionality provided by Object.factory is trivially
replaced by
a solution more specifically tailored to the problem at hand
using
compile-time reflection.
It's not quite trivial - somewhere there has to be a map and
registration and lookup and whatnot. I don't see it why it's
unbecoming for such functionality to be part of the standard
library. I would agree, however, that it's a judgment call
whether it should be wired in or provided on demand.
That s why this is a problem to add all that is the core of the
language when it isn't used often.