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

Identifier characters #7

Open
jdpage opened this issue Dec 7, 2017 · 3 comments
Open

Identifier characters #7

jdpage opened this issue Dec 7, 2017 · 3 comments

Comments

@jdpage
Copy link
Collaborator

jdpage commented Dec 7, 2017

Currently, pretty much any character is allowed in identifiers except for ()[]{}:.,"\, as long as the identifier begins with an alphabetical character. This is probably a little too liberal, though I would definitely like to preserve the following characters:

  • - -- I rather like kebab-case since you don't have to wildly mash the shift key to type multi-word identifiers. Lisps typically name things like this, though it does require that if you want to infix-subtract from a constant you have to put a space between them, which seems reasonable anyway.
  • ? -- useful for predicates. Ruby uses this.
  • ! -- useful for marking functions which change their arguments. Ruby again.
  • ' -- useful for marking helper/variation functions. Haskell this time.

I'm inclined to be pretty liberal about what goes in identifiers at first, especially since this isn't an especially punctuation-heavy language, though allowing ; and back-ticks inside identifiers rubs me the wrong way somehow.

@jdpage jdpage added the syntax label Dec 7, 2017
@woodrowbarlow
Copy link
Collaborator

woodrowbarlow commented Dec 7, 2017

my simple proposal:

  • must start with a letter.
  • may not contain any of the specials. this expands as we add more specials.

i hate single-quotes being used for things unclosed. it wreaks havok on the generic syntax highlighters that many editors apply when they don't recognize the source type (or when your source gets mis-recognized)... but that doesn't mean i want to disallow them. i just don't want to use them like that.

however, if we end up using single-quotes for something else then i will want to disallow it in identifiers. at that point it will probably be in our list of specials and will cause great lexers pains if its allowed in identifiers. speaking of which, do we have single-character literals?

i don't love semi-colons or back-ticks in identifiers (for the same reasons mentioned above), but don't see a reason to disallow them unless we want to reserve those for tokens

@woodrowbarlow
Copy link
Collaborator

here is my more formal proposal:

https://github.com/jdpage/jeff65/wiki/Identifiers

@jdpage
Copy link
Collaborator Author

jdpage commented Dec 7, 2017

Wiki might not be the best place for proposals -- it's hard to comment on them there, so I'd prefer that we created a directory containing proposals and then used branch/pr to track which ones are accepted and which ones are being workshopped.

Also, I actually don't like snake_case at all--the whole rationale for supporting kebab-case is that it's easier to type, so I'd prefer that identifiers in general, whether they be functions or variables, used kebab-case.

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

2 participants