https://d.puremagic.com/issues/show_bug.cgi?id=11658

           Summary: implicit conversion of associative array literal to
                    (typesafe variadic) tuple array
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from Martin Nowak <[email protected]> 2013-12-01 10:25:34 PST ---
The point is to add an implicit conversion rule so that
associative array literals can efficiently be passed
to a function.
Similar to how array literals could be passed on the stack (see bug 11657),
the AA literal elements could be passed as tuples.

----
MyAA!(Key, Value) myAA(Key, Value)(AATuple!(Key, Value)[] elems...)
{
}

unittest
{
    auto aa = myAA(["foo" : 0, "bar" : 1]);
}
----

It might be cleaner to generally allow the AA to array literal conversion.
----
AATuple!(string, int)[] ary = ["foo" : 0, "bar" : 1];
----

In lack of a standard tuple type we'd need to define a simple
    struct AATuple(Key, Value) { Key key; Value value; }
in object.

NB:
This should only apply to literals.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to