www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - [Associative arrays (AA)] static initializers

reply "Andrew Fedoniouk" <news terrainformatica.com> writes:
Are they feasible in foreseeable future?

int[char[]] m = { "one":1, "two":2 };
char[][int] m = { 1:"one", 2: "two" };

It could be extremely nice to have them...
( keeeping also in mind Matthew's enum2str
implementation )

I think that they could be implemented
internally as sorted (at compile time) key/value pairs
with binary search lookup.

As far as I can see they fit
in grammar without any changes.

Andrew Fedoniouk.
http://terrainformatica.com
Mar 10 2005
next sibling parent MicroWizard <MicroWizard_member pathlink.com> writes:
Would be very useful for any quick and (not too) dirty hacks/utilities
what I usually have to write.
I impatiently look forward for all the static array initialization solutions.

Tamas Nagy

Are they feasible in foreseeable future?

int[char[]] m = { "one":1, "two":2 };
char[][int] m = { 1:"one", 2: "two" };

It could be extremely nice to have them...
( keeeping also in mind Matthew's enum2str
implementation )

I think that they could be implemented
internally as sorted (at compile time) key/value pairs
with binary search lookup.

As far as I can see they fit
in grammar without any changes.

Andrew Fedoniouk.
http://terrainformatica.com

Mar 10 2005
prev sibling parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Andrew Fedoniouk wrote:
 Are they feasible in foreseeable future?
 
 int[char[]] m = { "one":1, "two":2 };
 char[][int] m = { 1:"one", 2: "two" };
 
 It could be extremely nice to have them...
 ( keeeping also in mind Matthew's enum2str
 implementation )

Been brought up before: D/26695 Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Mar 11 2005