Trying to understand a simple piece of code: dmd barray

Ferhat Kurtulmuş aferust at gmail.com
Sat Mar 7 15:01:15 UTC 2020


On Saturday, 7 March 2020 at 13:06:39 UTC, Dibyendu Majumdar 
wrote:
> On Saturday, 7 March 2020 at 12:26:32 UTC, drug wrote:
>
>>> I am trying to understand 
>>> https://github.com/dlang/dmd/blob/master/src/dmd/backend/barray.d.
>>> 
>>> Two questions:
>>> 
>>> 1. What does this mean and why is it needed?
>>> 
>>> line 95: alias array this;
>>> 
>> This means that `array` can be used instead of `this`
>
> Hmm should not that change the meaning of this throughout the 
> struct? is this good practice?
>
> Thank you

This is also a way of imitating inheritance in c-ish code without 
classes.


More information about the Digitalmars-d-learn mailing list