RT/CT Type
pham
home at home.com
Tue Apr 2 17:00:41 UTC 2019
On Tuesday, 2 April 2019 at 10:45:37 UTC, Jacob Carlborg wrote:
> On 2019-04-02 09:48, Alex wrote:
>> Since D has a highly evolved meta programming and it should
>> have unitifed type that works two ways:
>>
>>
>> This is a contrived example but I'm finding that I'm having to
>> use CTFE to deal with types which requires strings and then
>> convert those strings back in to types using string mixins,
>> which is a PIBA.
>
> I would much rather that D had first class types. That is, it
> would be possible to store types in variables and in arrays and
> so on.
Delphi has implemented class type for a long time. D should have
vision to implement it. However, D also needs to implement
inherited constructor in order for it to work
Skeleton sample in Delphi
type
A = class
create() virtual // constructor
writeln('A.create')
B = class(A)
create() override // constructor
//inherited create() // call inherited constructor implement
if needed
writeln('B.create')
ClassType = class of A; // Any class inherited from A can be used
to set to this type
ClassType x = A;
var x1 = x.create() // output 'A.create'
x = B
x1 = x.create() // output 'B.create'
Cheers
Pham
More information about the Digitalmars-d
mailing list