convert "class of" in pascal to D.

dennis luehring dl.soluz at gmx.net
Wed Jan 30 11:11:44 PST 2013


Am 30.01.2013 19:58, schrieb Paulo Pinto:
> Am 30.01.2013 18:18, schrieb dennis luehring:
>> in real OOP objects are specialized through its virtual method
>> implementations AND its ctor-parameters (which are similar in very very
>> few rare cases)
>>
>> for example pseudo code
>>
>> class Stream
>>    virtual read_bytes()...
>>
>>    class FileStream: Stream
>>      this(filename)
>>
>>    class NetworkStream: Stream
>>      this(tcp_ip,timeout)
>>
>> Stream[] streams
>>
>> streams ~= FileStream("c:/temp/test.txt");
>> streams ~= NetworkStream("123.112.2.1", 1000);
>>
>> stream[n].read_bytes()
>>
>> this is a much more common OOP/ctor situation then yours
>> i think its part of pascal/object delphi to ease the VCL development
>>
>> but this can be easily reached with an internal CreateInstance routine like
>>
>> Stream
>>    virtual Stream CreateInstance()
>>
>> and
>>    FileStream implements CreateInstance() with with return new FileStream
>>    NetworkStream "" with new NetworkStream etc.
>>
>> so whats the realy big deal/feature of this "class of"-type except for
>> very trivial OOP case
>
> Actually there are many definitions what real OOP means.
>
> As for Delphi's case, if I am not mistaken it tries to follow the
> metaclass concept that Smalltalk has, and Java/.NET have to a certain
> extent.

no there aren't many definitions but many many missuse of the concept
you interface is the adaptor, your virtual method code is the special 
behavior, your ctors parameters are the intialisers of the special 
behavior - everything else is just a pseudo-procedural style - its not 
OOP if you need to use casts and ifs on your object-type, thats 
procedural programming with class-based fake-namespaces

can you give me a small example of the metaclass concept of smalltalk - 
related to my simple stream example?



More information about the Digitalmars-d mailing list