Giter VIP home page Giter VIP logo

Comments (5)

Akuli avatar Akuli commented on September 3, 2024 2

We could try this again, because we no longer have a fuzzer. Non-ASCII variable names can lead to weird bugs where the variable name isn't what you think it is, but on the other hand, forcing everyone to program in English doesn't seem like a great idea either.

That said, I think we should do something more clever than just allowing all non-ASCII characters in variable names. For example, if you use non-breaking spaces, you can have working code that looks like this:

my awesome variable = 1

Here the "spaces" between words would be non-breaking spaces, not normal ASCII space characters, so if we just allow all non-ASCII characters in variable names, the compiler would sees the left side of = as one variable name. (Apparently GitHub replaces non-breaking spaces with normal spaces, so I can't actually write the above code example with them.)

It might be enough to ban all Unicode space characters in variable names. There's not that many, and it is relatively easy to find them with Python:

>>> [x for x in range(0x110000) if chr(x).isspace()]
[9, 10, 11, 12, 13, 28, 29, 30, 31, 32, 133, 160, 5760, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8232, 8233, 8239, 8287, 12288]

I am using range(0x110000) because I get this error message if I try to pass a big number to chr():

>>> chr(1000000000)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: chr() arg not in range(0x110000)

from jou.

Akuli avatar Akuli commented on September 3, 2024

Idea: Allow everything non-ASCII except characters in categories Cf, Cc, Zs, Zl, Zp. This is a total of 220 non-ASCII characters to ban.

from jou.

Akuli avatar Akuli commented on September 3, 2024

For now I think I will allow everything non-ASCII, but it could be better to emit errors for using e.g. non-breaking space as a variable name, or using an encoding other than UTF-8.

from jou.

Moosems avatar Moosems commented on September 3, 2024

Moosems: makes a newline into a variable.
Akuli: The..... What?

from jou.

littlewhitecloud avatar littlewhitecloud commented on September 3, 2024

So will the test fail again with non-ASCII variable names?

from jou.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.