Making generalized Trie type in D

Dmitry Olshansky dmitry.olsh at gmail.com
Mon Jun 4 10:35:55 PDT 2012


On 04.06.2012 16:15, Denis Shelomovskij wrote:
> 04.06.2012 13:46, Dmitry Olshansky написал:
>> enum keywords = [
>> "abstract",
>> "alias",
>> "align",
>> //... all of them, except @ ones
>> "__traits"
>> ];
>
> A nitpick: constant arrays should be defined as `immutable` instead of
> `enum`. `enum` means every time `keywords` used a new mutable array is
> dynamically allocated:
> ---
> auto x = keywords;
> auto y = keywords;
> assert(x !is y); // passes
> x[0] = ""; // legal, its mutable
> ---
>

Thanks, the mutable part is then a consequence of being another rvalue.
Obviously table should have been immutable.


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list