On Thu, 09 May 2013 02:33:08 +0200, bearophile wrote: > Byron Heads: > >> I have a variant associative array. In the example below I am >> wondering if there is a way to create the array without having to >> indicate the variant type on all of the values. Would like to be able >> to write code like #2, or something cleaner/better for #1. >> ... >> // #1 This works foo(["first" : HDType("John"), >> "last" : HDType("Doe"), "phone" : HDType(1234546)]); >> >> // #2 Wont compile, type mismatch string and long foo(["first" : >> "John", >> "last" : "Doe", >> "phone" : 1234546]); > > If your purpose is to write such associative literal without repeating > the HDType(), then a possibility is to write the data in a single > string, and feed it to a compile-time function that splits it and builds > the associative array. > > Bye, > bearophile
That approch may work. Will have to experiment with the API more.