Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?
Chad Joan
chadjoan at gmail.com
Thu Sep 27 04:20:58 UTC 2018
On Wednesday, 26 September 2018 at 23:32:36 UTC, Jonathan M Davis
wrote:
> On Wednesday, September 26, 2018 3:24:07 PM MDT Adam D. Ruppe
> via Digitalmars-d-learn wrote:
>> Object.factory kinda sux and I'd actually like to remove it
>> (among other people). There's no plan to actually do that, but
>> still, just on principle I want to turn people away.
>
> While there may not currently be plans to be remove it, as
> there _are_ plans to add ProtoObject as the new root class
> underneath Object, at some point here, it's likely that a large
> percentage of classes won't have anything to do with Object, so
> relying on Object.factory to be able to construct class Objects
> in general isn't likely to be a viable path in the long term -
> though presumably it would work for a code base that's written
> specifically with it in mind.
>
> Personally, I'm hoping that we eventually get to the point
> where Walter and Andrei are willing to outright deprecate
> Object itself, but I expect that ProtoObject will have to have
> been in use for a while before we have any chance of that
> happening. Either way, I think that it's clear that most code
> bases should go with a solution other than Object.factory if at
> all reasonably possible.
>
> - Jonathan M Davis
That's interesting! Thanks for mentioning.
If you don't mind, what are the complaints regarding Object? Or
can you link me to discussions/issues/documents that point out
the shortcomings/pitfalls?
I've probably run into a bunch of them, but I realize D has come
a long way since that original design and I wouldn't be surprised
if there's a lot more for me to learn here.
More information about the Digitalmars-d-learn
mailing list