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

Rename quote & friends to #%quote? #191

Closed
gelisam opened this issue Dec 30, 2022 · 3 comments
Closed

Rename quote & friends to #%quote? #191

gelisam opened this issue Dec 30, 2022 · 3 comments

Comments

@gelisam
Copy link
Owner

gelisam commented Dec 30, 2022

While using the name quote is more compatible with other lisps, using the name #%quote would be more consistent, because "foo" and '(foo) are both syntactic sugar for a macro call, namely (#%string "foo") and (quote (foo)).

@gelisam
Copy link
Owner Author

gelisam commented Dec 30, 2022

Btw @david-christiansen , is there a specific reason why users are forbidden from defining their own identifiers starting with #%? We could allow those characters inside identifiers and then a #lang could choose to rename quote to #%quote. Currently a #lang cannot do that because #% are not valid identifier characters but the parser makes an exception for #%string and the other special primitives.

@david-christiansen
Copy link
Collaborator

The reason is that they represent hooks that are used to allow user interpolation of operators into a context that is not otherwise syntactically marked. Otherwise, the variable naming system can be used to override the meanings of named operators (e.g. quote or lambda).

The reason to not allow other #% names is just to prevent confusion about what they do, and catch typos earlier. There's not a way for users to add new interpolation points, after all.

@gelisam
Copy link
Owner Author

gelisam commented Jan 1, 2023

Thanks for the explanation, the part about avoiding typos makes a lot of sense.

I now see that identifiers have three levels of discoverability:

  1. Identifiers like lambda appear as-is in the code, e.g. (lambda (x) x) becomes (lambda (x) x). Users can thus easily look up that identifier in the documentation.
  2. Identifiers like quote are shortened to a small number of special character, e.g. (open-syntax 'foo) becomes (open-syntax (quote foo)). Users can thus look up the special character in the documentation, but this requires making sure the documentation's search bar supports those special characters.
  3. Identifiers like #%app and #%string are inserted around existing code, without any syntactic markers, e.g. (f "foo") becomes (#%app f (#%string "foo")). Users might thus struggle to find the identifier's documentation, and might not even realize that an extra macro call is added.

It thus seems useful to keep the number of #% identifiers to a minimum, so that the user can read the entire section on #% identifiers and remember all the places where they are inserted. Therefore, I now agree not to rename quote to #%quote.

@gelisam gelisam closed this as completed Jan 1, 2023
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