DIP19: Remove comma operator from D and provision better syntactic support for tuples

Jacob Carlborg doob at me.com
Mon Sep 24 23:34:45 PDT 2012


On 2012-09-24 22:45, Nick Sabalausky wrote:

> Because 'b' is neither being assigned to an (int) nor passed into a
> template/func parameter that's expecting an (int).

Either I'm just stupid or I've failed completely to understand "implicit 
convertible to".

Another example:

struct Foo
{
     int[] arr;
     alias arr this;
}

void main ()
{
     auto foo = Foo([3, 4]);
     auto i = foo[0];
}

Have a look at the last line. In that line "foo" is implicitly converted 
to "int[]" with the help of the "alias this" in Foo, because the context 
requires something "indexable". Since you cannot index a struct the 
implicit conversion kicks in. What's the difference?

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list