DIP66 - Multiple alias this
12345swordy
alexanderheistermann at gmail.com
Mon Sep 28 20:23:20 UTC 2020
On Monday, 28 September 2020 at 19:55:10 UTC, Andrei Alexandrescu
wrote:
> On 9/28/20 2:44 PM, H. S. Teoh wrote:
>> On Mon, Sep 28, 2020 at 06:28:05PM +0000, mw via Digitalmars-d
>> wrote:
>>> On Monday, 28 September 2020 at 18:13:15 UTC, H. S. Teoh
>>> wrote:
>>>> On Mon, Sep 28, 2020 at 05:59:19PM +0000, mw via
>>>> Digitalmars-d wrote:
>>>>
>>>> As somebody already said, that's all well and good for
>>>> Eiffel. It's
>>>> not so clear how to integrate this nicely in D.
>>>
>>> D has `alias` already,
>> [...]
>>
>> `alias this` is one of the things that seemed like a good idea
>> at the
>> time, but is turning out to be something that leads to code
>> smells. If
>> anything, we'd like to get rid of it rather than extend it!
>
> I'd love to get a better idea about this, e.g. a few clear
> examples of bad uses and other few good examples where it's a
> win. My intuition vaguely revolves around "aliasing to an
> rvalue is bad and lvalue is good" but I year for clarity.
An example of bad use is when you "alias this" a class inside a
class. A good case is when you "alias this" a struct inside a
struct.
An ideal case for me is allowing classes to implement opimplicit
that strictly returns a copy of a value type, so that we can get
rid alias this for classes.
-Alex
More information about the Digitalmars-d
mailing list