Hiding class pointers -- was it a good idea?

James Dennett jdennett at acm.org
Thu Aug 16 22:35:45 PDT 2007


Walter Bright wrote:
> James Dennett wrote:
>> For one, rather restricted, notion of OOP.  There are many,
>> many views of what constitutes OOP in the PL community.
> 
> The definition I use is a common one, OOP design consists of three
> characteristics:
> 
> 1) inheritance
> 2) polymorphism
> 3) encapsulation

Then objects are in no way disallowed from having value semantics.

>>> In C++, an OOP class can be used/misused by the user as a value type or
>>> a reference type, all out of the purview of the class designer. The
>>> class designer must control this, not the class user.
>>
>> It's normal in C++ to make "entity" classes (those that
>> you're calling reference types) noncopyable.  It's also
>> normal to make base classes abstract.  Thus idioms easily
>> prevent the basic misuses.
> 
> C++ is loaded with idioms and conventions to try and head off major
> problems. I'd rather snip off such problems at the source - for one
> reason, it will dramatically reduce the learning curve of the language.
> For another, the more guarantees the language can offer, the lesser a
> burden it is on the code auditor, and the more likely the code is to be
> correct.

Valid points, though removing expressive power tends to move
the complexity into code, and it's hard to remove the power
to write bad code without also removing the power to write
great code.

-- James




More information about the Digitalmars-d mailing list