Why not extend do to allow unicode in ID's?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Tue Jul 2 04:34:42 UTC 2019


On Monday, July 1, 2019 8:56:55 PM MDT rikki cattermole via Digitalmars-d 
wrote:
> On 02/07/2019 2:17 PM, Jonathan M Davis wrote:
> > On Saturday, June 29, 2019 4:38:06 PM MDT Bert via Digitalmars-d wrote:
> >> It would greatly expand the coverage.
> >>
> >> It would be nice to use certain characters that are truly
> >> meaningful.
> >
> > ...
> >
> > Like most major languages, D supports identifiers with alphanumeric
> > characters plus underscore with the first character not being allowed to
> > be numeric. However, unlike most languages, it expands that to include
> > Unicode alpha characters, meaning that quite a lot of Unicode is
> > supported in identifiers. So, it already goes far beyond what most
> > languages do.
> >
> > That being said, I think that you'll find that most folks will not be in
> > favor of using Unicode in identifiers outside of code intended for
> > people of a specific language who actually use those characters
> > normally (e.g. Japanese characters when all of the programmers involved
> > read and write Japanese and have keyboards that support it). The fact
> > that a character is not a key on a typical keyboard means that anyone
> > using an identifier with that charater in it will almost certainly have
> > to copy-paste it, and that's really not going to over well with most
> > people. If you really feel strongly about the matter, you can always
> > create a DIP to propose a language change to allow more Unicode
> > characters in identifiers, but I would not expect it to be accepted.
> >
> > - Jonathan M Davis
>
> No DIP is required. The lexer just needs updating to match to the
> (current) Unicode spec.
>
> https://github.com/dlang/dmd/blob/master/src/dmd/lexer.d#L1082

If a character is a Unicode alpha character, then yes. However if it's not,
then that would definitely be a language change and would require a DIP. The
spec is quite specific about it requiring Unicode alpha characters, and the
code does the same. Without looking at the Unicode spec, I have no clue
which characters are alpha characters, but I'd be extremely surprised if a
character like ± or ♥ qualified.

- Jonathan M Davis






More information about the Digitalmars-d mailing list