[Issue 11658] New: implicit conversion of associative array literal to (typesafe variadic) tuple array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 1 10:25:36 PST 2013


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: nobody at puremagic.com
        ReportedBy: code at dawg.eu


--- Comment #0 from Martin Nowak <code at dawg.eu> 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: -------


More information about the Digitalmars-d-bugs mailing list