What would be the consequence of implementing interfaces as fat pointers ?

Walter Bright newshound2 at digitalmars.com
Mon Mar 31 01:16:40 PDT 2014


On 3/31/2014 12:51 AM, Manu wrote:
> Now it's deceptive that it's a pointer, and the pointer semantics are not
> suppressed. It might be surprising to find that a type that doesn't look like a
> pointer behaves like a pointer.
> You lose access to the operators, indexing/slicing etc, etc.
> I don't see how this is a reasonable comparison to 'class' as a reference type
> by definition.

Of course it's reasonable - not many classes overload operators.

The point is, there are numerous solutions available, you aren't stuck with one 
solution for every problem.

And, you can use 'alias this' as Adam showed to create a type with fully 
customized behavior - you don't have to change the language to prove your ideas.


More information about the Digitalmars-d mailing list