On Saturday, 28 December 2013 at 23:38:38 UTC, Ivan Kazmenko wrote:
Ouch, is it an exception hard-coded into the language itself? I thought it's just the nextPermutation's parameter type restrictions which don't allow "char []"...

No, a "char[]" is just a "char[]" as far as the language is concerned[1]. However, for the *phobos* range abstraction, (the front/popFront/empty) primitives, a char[] is a range of dchars. Once you've defined char[] as such a range, it affects all of phobos.

It's critiqued every now and then, but overall, it has proven to increase code correctness, at the cost (sometimes) of rejecting code that might be incorrect. Long story short: If you want to handle UTF, you have to handle it *explicitly*. *I* think it is a good compromise.

[1] the *only* place (AFAIK) that dmd looks at a string as a range of dchars is in a "foreach(dchar c; s)" loop. But even then, if you don't specify "dchar", then c will default to char.

Reply via email to