Making generalized Trie type in D

Roman D. Boiko rb at d-coding.com
Mon Jun 4 11:46:17 PDT 2012


On Monday, 4 June 2012 at 12:15:33 UTC, 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
> ---

Well, in my case they were only used for mixin code generation 
(IIRC). Dmitry obviously has a different situation.


More information about the Digitalmars-d mailing list