https://d.puremagic.com/issues/show_bug.cgi?id=11658
Igor Stepanov <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #1 from Igor Stepanov <[email protected]> 2013-12-01 13:46:07 PST --- IMO, it's more then need to AA and less then need to user types. First AA literal usage that I see is an JSONValue initialization: JSONValue var = [ "Key1":42L, "Key2":"foo", "Key3":[1, "bar", 12.7] ]; I suggest another way to implement this feature. 1. declare in in object two structs: struct AssociativeArrayLiteral(T...) { //void } struct ArrayLiteral(T...) { //void } 2. Allow converting [a:b, c:d] to AssociativeArrayLiteral!(a, b, c, d)() and [a, b, c, d] to ArrayLiteral!(a, b, c) 3. User can implement his type like the following: struct MyJSON { this(T)(T var) { static if(is(T : AssociativeArrayLiteral!TL, TL...)) { pragma(msg, TL.stringof); //TL is an expanded AA-literal tuple } else { static assert(0); } } } 4. By default [a:[b,c,d]] should converts to associative array with key `a` and D-array value [b,c,d], but if outer literal boxed to AssociativeArrayLiteral, inner literal should be boxed to ArrayLiteral without attempting to represent it as standart D array, even if it possible. If a user wants to control parsing of outer literal manually then only he knows how to parse inner literals. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
