Semantics of :: in return type vs. argument type annotations

This isn’t unreasonable — UInt32(char) == codepoint is probably the most obvious representation of a Unicode Char, and I expect that it is the one used in most other languages.

It used to be the representation in Julia, too, but it was changed to the current representation in julia#24999 (also described in Changes to the representation of Char - #5 by StefanKarpinski), the result of an inspiration by @StefanKarpinski. The big benefit was the ability to represent invalid UTF-8 encodings, so that string iteration doesn’t break if there is random binary data mixed in. For example, collect(String(rand(UInt8, 100))) works. (It also made string iteration slightly faster, since you no longer have to fully decode the UTF-8 to get a Char.)

7 Likes