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

Bert Bert at gmail.com
Sat Jun 29 22:38:06 UTC 2019


It would greatly expand the coverage.

It would be nice to use certain characters that are truly 
meaningful.

In fact, it would be nice for ops too.

░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼
∩ε≡φ±≥≤⌠⌡÷≈∙·√ⁿ²■☺♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼

I realize the excuse is going to be "It makes the code look ugly 
or hard to read", not all editors will support it, etc...

So? Those are lame excuses. People can abuse anything, you can't 
police the world. Stopping all legitimate uses because someone 
might use it illegitimately is ignorant and harmful(which is why 
it is ignorant).

It is best to enable unicode support and then have standards and 
guidelines and let some people shoot themselves in the foot if 
they want... that is the best way to learn not to do it again.

Imagine being able to write proper mathematical formula ID's:

∞
δ
Ω
Θ
Φ
τ
µ
σ
ε
φ

or using valid mathematical operators:

∩
≡
±
≥
≤
÷
≈
∙
√
ⁿ
²

or when you write a card game:

♥
♦
♣
♠


These are much better than the verbose words that we have to use 
now. I know some will say the opposite, but they can say it and 
be wrong. Trying to stop me from shooting myself in the foot when 
I don't own a gun is abusive to me and just like shooting me in 
the foot! I don't write any code that anyone else reads so let me 
make the choice for myself rather than create arbitrary rules 
that limit expressiveness. There is a reason the first amendment 
exists in the US, because the founders knew what limitations of 
expression would do. The same applies to all things.

Maybe one could use a switch to enable such a language with a 
compiler warning about such use. Maybe we can have a special D 
code page for useful symbols so there is a standard code for each 
that one could properly map using their editor of choice?

For example, we could have each symbol map to a long name that 
one could use to replace the source:

♥ = Symbol_Heart_0x2660    // or even just __Symbol__0x2660
♦ = Symbol_Diamond_0x2661
♣ = Symbol_Club_0x2662
♠ = Symbol_Spade_0x2663

And one could then change any source code between the symbolic 
form and the verbose form using a command line utility.

E.g.,


int ♥ = 3;

Can be converted to

int Symbol_Heart_0x2660 = 3;

and back without issue(99.9999999999% of code).

This would potentially cause issue with meta programming when 
comparing string of the id names but this is a minor issue. In 
fact, internally D could just use the long symbol name and 
require the programmer to use them.

E.g.,

static if (id == "♥") // invalid if id gets converted to long 
name internally.

static if (id == #"♥") // valid: #(or whatever) converts the 
symbol to it's long name

There are solutions to the problems... let's work on finding one 
to make D better.











More information about the Digitalmars-d mailing list