Comments (5)
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.
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.
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: makes a newline into a variable.
Akuli: The..... What?
from jou.
So will the test fail again with non-ASCII variable names?
from jou.
Related Issues (20)
- `as` precedence HOT 1
- compiler segfault when struct contains array of pointers to itself
- bool == bool HOT 2
- byte < byte
- sometimes error message for using . in class is misleading HOT 3
- `assert True` --> weird warning HOT 2
- compiler doesn't seem to understand what `not` does to booleans
- Methods that take self by value
- Error: the '&' operator cannot be used with a field of self
- Dunder methods? HOT 5
- Compile time struct HOT 6
- tutorial: Explain when to use pointer HOT 1
- Platform if statements inside class
- doctest netbsd base64 error HOT 2
- Release description
- no expf() function HOT 4
- Replace the full path to 'Jou'? HOT 5
- Sharing compiled binaries HOT 1
- compiler internals: AST_STMT_FUNCTION is weird
- Rename long to int64? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jou.