Trying to understand a simple piece of code: dmd barray
Steven Schveighoffer
schveiguy at gmail.com
Sat Mar 7 13:01:05 UTC 2020
On 3/7/20 7:26 AM, drug wrote:
> 07.03.2020 15:05, Dibyendu Majumdar пишет:
>> Hi,
>>
>> 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`
To expand on this, the compiler basically substitutes the symbol aliased
here for the item itself if all other members are a compiler error.
So for example, if you have:
barr.length;
and barr has no member length, it tries:
barr.array.length
-Steve
More information about the Digitalmars-d-learn
mailing list