Making generalized Trie type in D

Denis Shelomovskij verylonglogin.reg at gmail.com
Mon Jun 4 05:15:37 PDT 2012


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
---

-- 
Денис В. Шеломовский
Denis V. Shelomovskij


More information about the Digitalmars-d mailing list