opDispatch and alias this

aliak something at something.com
Tue Jun 26 03:07:08 UTC 2018


On Monday, 25 June 2018 at 23:13:12 UTC, Seb wrote:
> Apparently three years ago it was we decided to ban alias this 
> and opDispatch in the same class.
> What are your thoughts on this now?
> Is anyone depending on using alias this + opDispatch together 
> like e.g. in https://github.com/dlang/phobos/pull/6596?

Yes! I at least depend on it: 
https://github.com/aliak00/optional/blob/master/source/optional/dispatcher.d And it's very deliberate as well, and not sure there's a workaround if this is banned. Or is there?

I went thought the DIP and I'm not sure I could exactly 
understand where the problems were - The first two-thirds seems 
to describe how alias this is used? Is that correct?

The sections Resolution Algorithm first describes how it "should" 
be resolved right? I didn't understand if that is different than 
the current resolution (is it?) and how though. Is the recursive 
alias this a problem or is that just a "btw, you can do this" 
kinda thing.

The Limitation section also says that opDispatch and alias this 
shouldn't be allowed, but why?

I think maybe the DIP seems to mix "will" and "should"? so it 
makes it hard to see what is the current behavior and what the 
behavior should be?

There is also no link to any discussions either - I see there was 
a forum discussion 4 years ago though, was that part of the DIP 
review process? - and going through it there were some questions 
for e.g. walter, timon, among others that I don't _think_ are 
answered in the dip.

Also, what would the work around be for code that relies on 
opDispatch and alias this? And shouldn't the PR take in to 
account the "Deprecation process" and deprecate it first before 
banning it?

Cheers,
- Ali



More information about the Digitalmars-d mailing list