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

Manu turkeyman at gmail.com
Mon Mar 31 00:51:17 PDT 2014


On 31 March 2014 17:28, Walter Bright <newshound2 at digitalmars.com> wrote:

> On 3/30/2014 8:32 PM, Adam D. Ruppe wrote:
>
>> On Monday, 31 March 2014 at 03:25:11 UTC, Manu wrote:
>>
>>> I also feel quite dirty using pointers in D where there is a dedicated
>>> reference type available. I don't want * and & to appear everywhere in
>>> my D code.
>>>
>>
>> structs can pretty easily be reference types too:
>>
>
> Or just:
>
>    alias S* C;
>
> Voila! Use C as the type instead of S*. The reason this works out so well
> in D is because C.member works (no need to use -> )
>

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140331/64ec31df/attachment.html>


More information about the Digitalmars-d mailing list