enum-indexed arrays

"Nordlöw" via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Sep 20 14:43:55 PDT 2014


On Saturday, 20 September 2014 at 21:05:12 UTC, Nordlöw wrote:
> On Saturday, 20 September 2014 at 20:43:28 UTC, bearophile 
> wrote:
>> In D currently that "int[I]" is an associative array with I 
>> index and int values. So in another post I have suggested 
>> another syntax.
>
> Couldn't we simply add an optimization pass that CT-introspects 
> the enumerators of an enum-indexed AA and represent it 
> internally as a lookup-table if the enumerator values are 
> adjacent (enough)?

Further it would be nice if the newly added std.range.enumerate 
got support for Enumerator being an enum when instantiated with 
an enum-indexed array.

Currently it fails, for starters, because the default value of 
second parameter

     Enumerator start = 0

should be

     Enumerator start = Enumerator.min

in the case when Enumerator is an enum.


More information about the Digitalmars-d-learn mailing list