Unicode symbols in the identifiers

Jacob Carlborg doob at me.com
Fri Jan 11 02:16:11 PST 2013


On 2013-01-11 03:09, Andrey wrote:
> Should these variants serve as identifiers?
>
> auto x²; //fails to compile: char 0x00b2 not allowed in identifier,
> unsupported char 0xb2 (why? is it not a digit?)
>
> Same for ⅀, ∫ and etc.
>
> Official documentations says:
> «
> D source text can be in one of the following formats:
> ASCII
> UTF-8
> UTF-16BE
> UTF-16LE
> UTF-32BE
> UTF-32LE
> »
>
> Math symbols could have a great use compare to just characters from
> other languages (who does code in Greek or Chinese?). Still, this
> function name in russian cause compile error: 2.вквадрате (вквадрате(2))

According to the specification D doesn't necessarly support unicode 
identifiers:

"Identifiers start with a letter, _, or universal alpha, and are 
followed by any number of letters, _, digits, or universal alphas. 
Universal alphas are as defined in ISO/IEC 9899:1999(E) Appendix D. 
(This is the C99 Standard.) Identifiers can be arbitrarily long, and are 
case sensitive. Identifiers starting with __ (two underscores) are 
reserved."

http://dlang.org/lex.html#Identifier

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list