http://d.puremagic.com/issues/show_bug.cgi?id=8143



--- Comment #16 from bearophile_h...@eml.cc 2012-10-24 18:38:41 PDT ---
(In reply to comment #15)

> Ah it took me a while to realize you were looking for CTFE ability.

Sorry for not being more clear.

Another significant test case, this is useful in many simulations and games, to
write safe tables and start conditions:


enum Code : char { A='A', B='B', C='C' }

void test()
{
...
    const code = to!(Code[][])(["ABCCBA", "BBAA"]);
    with (Code)
        assert(code == [[A, B, C, C, B, A], [B, B, A, A]]);
}


The main problem with this is that you receive conversion errors only at
run-time, and in D the problem with array compile-time constants is that the
compiler re-creates them every time where you use them. So they are not so
useful.

------------------

Unfortunately this is not yet allowed because to!() is not pure:

immutable code = to!(Code[][])(["ABCCBA", "BBAA"]);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to