Array literals' default type

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Sat Oct 10 16:22:56 PDT 2009


Michel Fortin wrote:
> On 2009-10-10 12:12:27 -0400, "Lars T. Kyllingstad" 
> <public at kyllingen.NOSPAMnet> said:
> 
>> Christopher Wright wrote:
>>> Don wrote:
>>>> At worst, it would be something like:
>>>>
>>>> exec("description", createArray(procName, arg1, arg2) ~ 
>>>> generatedArgs ~ createArray(arg3, arg4) ~ moreGeneratedArgs);
>>>
>>> PHP does this. I haven't used PHP enough to hate it.
>>
>>
>> I've used PHP a fair bit, and I don't hate its array syntax at all. 
>> (There are plenty of other things in PHP to hate, though.) It's easily 
>> readable, and not much of a hassle to write. But array() in PHP isn't 
>> a function, it's a language construct with special syntax. To create 
>> an AA, for instance, you'd write
>>
>>    $colours = array("apple" => "red", "pear" => "green");
>>
>> I'm not sure what the D equivalent of that one should be.
> 
> Associative array literals:
> 
>     string[string] s = ["hello": "world", "foo": "bar"];


I know that. :) I was just wondering what the equivalent function call 
should look like if we replaced array literals with functions, cf. the 
createArray() function above.

-Lars



More information about the Digitalmars-d mailing list