Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed convention: prefix for "normal" identifiers #98

Open
qwertie opened this issue Jan 29, 2020 · 0 comments
Open

Proposed convention: prefix for "normal" identifiers #98

qwertie opened this issue Jan 29, 2020 · 0 comments

Comments

@qwertie
Copy link
Owner

qwertie commented Jan 29, 2020

By convention, the first character of any identifier in a Loyc tree determines whether or not it is "special": ASCII codes under 40 are special, all others are "normal" identifiers. In particular, # identifies constructs (classes, namespaces, functions, for-loops, etc.), ' identifies operators ('+, '>>, '&&, etc.), and % identifies trivia (comments, newlines, etc.)

Ahh, but what if there is a language that uses allows one of these characters under 40 in a "normal" identifier? Then it would seem that the Loyc tree for that identifier should be encoded with a "normalcy" prefix to indicate it is not special, and the prefix should have an ASCII code >= 40.

I'm going to propose the + prefix for this purpose, so that if #foo is intended to be a "normal" identifier, it should be encoded as +#foo. Why plus? Mainly because, in most contexts, it is not already used for some other purpose... I considered comma , but in LES2 it is easier to escape the plus sign + (@+#foo vs @`,#foo`).

This rule is intended for encoding languages outside the Loyc project, and it is not a proposal to change existing code. It does not apply to LES, because a major purpose of LES is to express the contents of Loyc trees, including "special" ones. The lexer of LES treats # like a "normal" identifier character, but the reason for this is to be able to encode #special identifiers easily without any escaping mechanism. So if you write #foo in LES, the Symbol #foo will be stored (not +#foo). This rule does not apply to Enhanced C# either, largely for a historical reason (EC# was originally intended to play the role of encoding Loyc trees that LES plays now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant