DIP66 - Multiple alias this
IgorStepanov via Digitalmars-d
digitalmars-d at puremagic.com
Sun Oct 12 16:16:33 PDT 2014
On Sunday, 12 October 2014 at 23:02:13 UTC, Steven Schveighoffer
wrote:
> On 10/10/14 6:10 PM, IgorStepanov wrote:
>> On Friday, 10 October 2014 at 21:26:49 UTC, Steven
>> Schveighoffer wrote:
>
>>> An example:
>>>
>>> foo(T)(T t) if(is(T : int))
>>> {
>>> someFuncThatTakesInt(t);
>>> }
>>>
>>> foo(T)(T t) if(!is(T : int) && is(T.shadow : int))
>>> {
>>> someFuncThatTakesInt(t.shadow);
>>> }
>>>
>>> struct A
>>> {
>>> int i;
>>> alias i this;
>>> }
>>>
>>> struct B
>>> {
>>> int i;
>>> alias i this;
>>> }
>>>
>>> struct C
>>> {
>>> A a;
>>> B shadow;
>>> alias a this;
>>> alias shadow this;
>>> }
>>>
>>> C c;
>>> foo(c); // should compile, but I think your DIP makes it fail
>>> due to
>>> ambiguity
>>>
>>
>> You can write foo(c.shadow); This isn't hard.
>> Ok, I understood you, let's listen to what others say
>
> Right, you can get around it.
>
> But the issue here is, that I feel like is(T: U) means (from
> dlang.org):
>
> is ( Type : TypeSpecialization )
> The condition is satisfied if Type is semantically correct and
> it is the same as or can be implicitly converted to
> TypeSpecialization.
>
> This means is(C : int) should indicate that C can implicitly
> convert to int. But in your DIP, it does not. I think this is
> incorrect.
>
> -Steve
Hmm. I've written case (my previous post), when returning false
from is(T: S), where T has many pathes to S is dangerous. However
your words also contain the truth. I don't know what we need to
do. Maybe we should raise error during "is" semantic? Please,
read my example and say your opinion.
More information about the Digitalmars-d
mailing list