Uniform Function Call Syntax?

Chris Wright via Digitalmars-d digitalmars-d at puremagic.com
Mon Mar 7 10:35:44 PST 2016


On Mon, 07 Mar 2016 10:32:09 +0000, Ola Fosheim Grøstad wrote:
> D is inconsistent in what parts
> of unicode you can use in names though.

The basic idea is that you can use any letter or '_' as the first element 
of an identifier, and you can use any letter or number or '_' as a 
subsequent element of an identifier. That's simple and consistent, right?

Except it's based on C99's fixed list of characters. So the actual rule 
is, you can use symbols from about 25 different writing systems that the 
designers of C99 thought prevalent enough to include, so long as they 
were in Unicode before 1999.

C#, in contrast, uses Unicode categories. You can use the Cherokee 
alphabet in C# identifiers, and there are under 400,000 speakers of 
Cherokee. Making that work took far less effort for the C# standard 
authors than the choice of identifier characters for C99.

I'm relatively certain that Walter went with C99's rules in large part 
because he had already implemented them, whereas he didn't have a readily 
available library with an appropriate license to give the Unicode 
category for a given codepoint.

> But you can already use "π" in D code?

U+03C0 (π) is from the Greek alphabet section of the Unicode inventory. 
It's for writing in the Greek language, which is currently spoken by 
about thirteen million people. It is primarily a letter, with incidental 
usage as a mathematical symbol.

Therefore, based on the rule that you can always start an identifier with 
a letter, you can use π as an identifier.

> I don't think you can use "∂"...

The partial integral symbol is not a letter or digit under any 
circumstances. It is a mathematical symbol. Identifiers cannot contain 
mathematical symbols in D or C99 or even C#.


More information about the Digitalmars-d mailing list