[OT] Modules dropped out of C++17

via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 9 07:05:38 PDT 2015


On Tuesday, 9 June 2015 at 11:39:49 UTC, Kagamin wrote:
> Not sure how physical layout of source code affects 
> understanding of "libraryobject.print()".

One of the arguments for having separate declarations and 
definitions in C++ is that it provides better encapsulation 
(which C++ breaks for templates and inlined methods).

If you have full encapsulation you know that the declaration 
holds. So "x.print()" means that the declaration for the type of 
x includes "print()". That also affects what "print()" can 
reasonably be expected to affect.

>> Subclassing is usually the better option.
>
> In statically typed languages you don't control types you 
> receive from 3rd party code.

True, but you can always wrap code in interfacing-references. I 
use this deliberately in multi-threaded code, so that I avoid 
calling the wrong methods on the wrong thread. E.g. 
"multithreaded(someobject).clear()" and 
"singlethreaded(someobject).clear()".


More information about the Digitalmars-d mailing list