bearophile wrote:
Benji Smith:
    // Defaults to using built-in associative array type
    auto assocArray = [
       "hello" : "world
    ];

    // Uses my own custom type.
    auto hashtable = MyHashTableType!(string, string) [
       "hello" : "world
    ];

In the second case the type inference of the compiler may find the types from 
the AA literal itself:

auto hashtable = MyHashTableType ["hello" : "world];

Bye,
bearophile

If that were the case, I'd want the compiler to scan *all* the key/value pairs for instances of derived types (rather than just being based on the first K/V pair, like is currently the case with other array literals).

For example (using tango classes, where HttpGet and HttpPost are both subclasses of HttpClient):

   // Type is: MyHashTableType!(string, HttpClient)
   auto hashtable = MyHashTableType [
      "get"  : new HttpGet(),
      "post" : new HttpPost()
   ];

Reply via email to