Thread overview | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 07, 2014 "alias that this" or "alias this : that" | ||||
---|---|---|---|---|
| ||||
Can someone please clarify for me which of these is the "preferred" syntax? alias that this; alias this : that; The documentation here (http://dlang.org/class.html#AliasThis) doesn't mention the latter. I'll do the unrewarding work of updating the docs if someone could just please tell me which syntax the core language folks prefer. Thanks. Mike For context: https://github.com/D-Programming-Language/dmd/pull/1413 https://github.com/D-Programming-Language/dmd/pull/1685 |
February 07, 2014 Re: "alias that this" or "alias this : that" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike | On Friday, 7 February 2014 at 07:36:57 UTC, Mike wrote:
> Can someone please clarify for me which of these is the "preferred" syntax?
>
> alias that this;
> alias this : that;
>
> The documentation here (http://dlang.org/class.html#AliasThis) doesn't mention the latter. I'll do the unrewarding work of updating the docs if someone could just please tell me which syntax the core language folks prefer.
>
> Thanks.
> Mike
>
> For context:
> https://github.com/D-Programming-Language/dmd/pull/1413
> https://github.com/D-Programming-Language/dmd/pull/1685
`alias this : that` was discussed but has never been implemented, so currently the only way to do it is `alias that this`.
|
February 07, 2014 Re: "alias that this" or "alias this : that" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On Friday, 7 February 2014 at 07:52:22 UTC, Meta wrote:
> On Friday, 7 February 2014 at 07:36:57 UTC, Mike wrote:
>> Can someone please clarify for me which of these is the "preferred" syntax?
>>
>> alias that this;
>> alias this : that;
>>
>> The documentation here (http://dlang.org/class.html#AliasThis) doesn't mention the latter. I'll do the unrewarding work of updating the docs if someone could just please tell me which syntax the core language folks prefer.
>>
>> Thanks.
>> Mike
>>
>> For context:
>> https://github.com/D-Programming-Language/dmd/pull/1413
>> https://github.com/D-Programming-Language/dmd/pull/1685
>
> `alias this : that` was discussed but has never been implemented, so currently the only way to do it is `alias that this`.
Is alias this = that not a thing? If not, why?
|
February 07, 2014 Re: "alias that this" or "alias this : that" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tofu Ninja | On Friday, 7 February 2014 at 20:48:37 UTC, Tofu Ninja wrote:
> On Friday, 7 February 2014 at 07:52:22 UTC, Meta wrote:
>> On Friday, 7 February 2014 at 07:36:57 UTC, Mike wrote:
>>> Can someone please clarify for me which of these is the "preferred" syntax?
>>>
>>> alias that this;
>>> alias this : that;
>>>
>>> The documentation here (http://dlang.org/class.html#AliasThis) doesn't mention the latter. I'll do the unrewarding work of updating the docs if someone could just please tell me which syntax the core language folks prefer.
>>>
>>> Thanks.
>>> Mike
>>>
>>> For context:
>>> https://github.com/D-Programming-Language/dmd/pull/1413
>>> https://github.com/D-Programming-Language/dmd/pull/1685
>>
>> `alias this : that` was discussed but has never been implemented, so currently the only way to do it is `alias that this`.
>
> Is alias this = that not a thing? If not, why?
Because
alias this = that;
alias this = anotherThat;
is wierd
|
February 07, 2014 Re: "alias that this" or "alias this : that" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozak | On 02/07/2014 10:02 PM, Daniel Kozak wrote:
> On Friday, 7 February 2014 at 20:48:37 UTC, Tofu Ninja wrote:
>> On Friday, 7 February 2014 at 07:52:22 UTC, Meta wrote:
>>> ...
>>
>> Is alias this = that not a thing? If not, why?
> Because
> alias this = that;
> alias this = anotherThat;
>
> is wierd
Even if we assume for now that this is somehow bad, it is no reason to have syntax inconsistent with alias.
int baz(int x){ return x; }
double bar(double x){ return x; }
alias foo = bar;
alias foo = baz;
|
February 07, 2014 Re: "alias that this" or "alias this : that" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | On Friday, 7 February 2014 at 21:30:46 UTC, Timon Gehr wrote:
> On 02/07/2014 10:02 PM, Daniel Kozak wrote:
>> On Friday, 7 February 2014 at 20:48:37 UTC, Tofu Ninja wrote:
>>> On Friday, 7 February 2014 at 07:52:22 UTC, Meta wrote:
>>>> ...
>>>
>>> Is alias this = that not a thing? If not, why?
>> Because
>> alias this = that;
>> alias this = anotherThat;
>>
>> is wierd
>
> Even if we assume for now that this is somehow bad, it is no reason to have syntax inconsistent with alias.
>
> int baz(int x){ return x; }
> double bar(double x){ return x; }
>
> alias foo = bar;
> alias foo = baz;
+1
|
February 07, 2014 Re: "alias that this" or "alias this : that" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike | On Friday, 7 February 2014 at 07:36:57 UTC, Mike wrote:
> Can someone please clarify for me which of these is the "preferred" syntax?
>
> alias that this;
> alias this : that;
>
> The documentation here (http://dlang.org/class.html#AliasThis) doesn't mention the latter. I'll do the unrewarding work of updating the docs if someone could just please tell me which syntax the core language folks prefer.
>
> Thanks.
> Mike
>
> For context:
> https://github.com/D-Programming-Language/dmd/pull/1413
> https://github.com/D-Programming-Language/dmd/pull/1685
I'd like for 'alias that this' to go away.
I'm fine with 'alias this = that'
If we must 'alias this : that' or "this implicitly casts to that" is also reasonable to me.
Yes 'alias that this' can stay for backwards compatibility.
No 'alias this : that' has not been implemented (that I'm aware of).
|
February 07, 2014 Re: "alias that this" or "alias this : that" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | On Friday, 7 February 2014 at 21:30:46 UTC, Timon Gehr wrote:
> On 02/07/2014 10:02 PM, Daniel Kozak wrote:
>> On Friday, 7 February 2014 at 20:48:37 UTC, Tofu Ninja wrote:
>>> On Friday, 7 February 2014 at 07:52:22 UTC, Meta wrote:
>>>> ...
>>>
>>> Is alias this = that not a thing? If not, why?
>> Because
>> alias this = that;
>> alias this = anotherThat;
>>
>> is wierd
>
> Even if we assume for now that this is somehow bad, it is no reason to have syntax inconsistent with alias.
>
> int baz(int x){ return x; }
> double bar(double x){ return x; }
>
> alias foo = bar;
> alias foo = baz;
Reserving `alias this = ...;` allows adding aliasing of constructors in the future, assuming it can be meaningfully defined.
|
February 07, 2014 Re: "alias that this" or "alias this : that" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jakob Ovrum | On 02/07/2014 11:23 PM, Jakob Ovrum wrote:
>>
>
> Reserving `alias this = ...;` allows adding aliasing of constructors in
> the future, assuming it can be meaningfully defined.
What a mess that would be. If the consensus is that alias this syntax was a mistake then _both_ forms should be removed and the concept should be re-introduced as specially named member instead.
|
February 07, 2014 Re: "alias that this" or "alias this : that" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | On Friday, 7 February 2014 at 22:55:05 UTC, Timon Gehr wrote:
> On 02/07/2014 11:23 PM, Jakob Ovrum wrote:
>>>
>>
>> Reserving `alias this = ...;` allows adding aliasing of constructors in
>> the future, assuming it can be meaningfully defined.
>
> What a mess that would be. If the consensus is that alias this syntax was a mistake then _both_ forms should be removed and the concept should be re-introduced as specially named member instead.
Timon, this makes a lot of sense. Would you mind elaborating with a simple syntax sample?
|
Copyright © 1999-2021 by the D Language Foundation