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

Manu turkeyman at gmail.com
Sun Mar 30 21:47:46 PDT 2014


On 31 March 2014 13:32, Adam D. Ruppe <destructionator at gmail.com> 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:
>
> struct RefType {
>    struct Impl {
>         // put all the stuff in here
>    }
>    Impl* impl;
>    alias impl this;
>
>    // add ctors and stuff that new the impl
> }
>

And you think this is 'cool'?
The amount of boilerplate required makes C++ look neat and tidy. You've
also truncated it significantly.

class RefType
{
  // put all the stuff in here
}


Why would anyone want to do all that crap? The reason is to overcome the
limitations/restrictions of class... so just fix class?
Or maybe improve struct, so that boilerplate can disappear.
Perhaps add a distinct ref type like MS did with '^' pointers in WinRT and
managed C++?

Either way, for my money, that code might appeal to a D nerd (because you
'can'!), but I find it acutely distasteful code otherwise.
No junior programmer would/should understand all that intuitively, and I
would be embarrassed to show that to a non-D-user that I was trying to
convince.

If this pattern is recurring (it seems that it is), then I think it's clear
sign of a chronic deficiency in D. It should probably be studied and
addressed. I'm seeing it appear a lot.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140331/ecd6cb2a/attachment-0001.html>


More information about the Digitalmars-d mailing list