Special Type Challenge

via Digitalmars-d digitalmars-d at puremagic.com
Sun Feb 8 05:06:06 PST 2015


On Saturday, 7 February 2015 at 20:53:48 UTC, Meta wrote:
> On Saturday, 7 February 2015 at 19:38:10 UTC, Marc Schütz wrote:
>> On Saturday, 7 February 2015 at 05:27:39 UTC, Andrei 
>> Alexandrescu wrote:
>>> On 2/6/15 8:28 PM, Jonathan Marler wrote:
>>>> Do you know if D might support that later or if there's a 
>>>> reason for not
>>>> supporting it?
>>>
>>> It's deliberate following the C++ experience. -- Andrei
>>
>> Hasn't there been a debate about a hypothetical 
>> `opImplicitCast()`? The default would still be off, but you 
>> can opt-in by defining said method.
>
> `alias this` is pretty much `opImplicitCast`, but it currently 
> has a few holes, such as 
> http://forum.dlang.org/post/xcnwuneclebuyqcjbkwu@forum.dlang.org. 
> It's not always appropriate in every situation though, as you 
> get full-on subtyping along with implicit conversion.

No, `alias this` convert from the type it is declared in to 
another type. `opImplicitCast` would be declared in the 
destination type.


More information about the Digitalmars-d mailing list