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

Chris wendlec at tcd.ie
Mon Mar 31 03:41:43 PDT 2014


On Monday, 31 March 2014 at 03:25:11 UTC, Manu wrote:
> On 31 March 2014 12:21, Walter Bright 
> <newshound2 at digitalmars.com> wrote:
>
>> On 3/30/2014 6:33 PM, Manu wrote:
>>
>>> This is an interesting idea. Something I never thought of, 
>>> and I think I
>>> like it!
>>>
>>
>> Frankly, I don't know why you use classes at all. Just use 
>> structs.
>>
>
> Reference types are very useful. Most programmers are familiar 
> with this
> workflow, and it's a convenient way of modelling lots of 
> problems.
>
> I do find myself using a lot more struct's in D though, but 
> that doesn't
> void the traditional approach. And I also maintain that these 
> things are
> important particularly as a bridge for new D users.
> 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.

Again and again I find myself reluctantly turning a struct into a 
class simply to get the reference semantics. Sure I could find 
work arounds and use * and & etc., but it just does not feel 
right, because hacks should only be the last resort, not 
something that is all over the place in your code. As has been 
mentioned earlier in this thread, these things often come back 
and bite you and all of a sudden it doesn't seem "so clever" 
anymore. On the other hand, I don't think that we should change 
the language, because of random annoyances that might partly be 
down to our design decisions taken earlier in the code.


More information about the Digitalmars-d mailing list