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

Kebab-Case Identifiers in Expression Mode #2088

Open
PossiblyAShrub opened this issue Oct 2, 2024 · 1 comment
Open

Kebab-Case Identifiers in Expression Mode #2088

PossiblyAShrub opened this issue Oct 2, 2024 · 1 comment

Comments

@PossiblyAShrub
Copy link
Collaborator

From Zulip: #language-design>Kebab-Case literal syntax

I'm finding that getVar("my-proc") feels really jarring. It's nice for the dynamic case, but I'd like to somehow reference my-proc without getVar...

Rust has a r#ident syntax for restricted keywords:

error: expected identifier, found keyword `else`
  --> $DIR/keyword-else-as-identifier.rs:4:9
   |
LL |     let else = "foo";
   |         ^^^^ expected identifier, found keyword
   |
help: escape `else` to use it as an identifier
   |
LL |     let r#else = "foo";
   |         ++

error: aborting due to 1 previous error

Could we extend this so we can write y#my-proc or y#else?

Current ideas are:

  • y#my-proc or r#my-proc
  • `my-proc`
@andychu
Copy link
Contributor

andychu commented Oct 2, 2024

This kind of thing is also useful for metaprogramming

for example in mycpp we have to special case flag.extern, derived from --extern, as flag.extern_

Because extern is a C++ keyword

We also have the same issue with Python keywords

So if we provide a function quoteName() or ${x|yshName}, which does the correct quoting, then it will make metaprogramming slightly cleaner


This is slightly related to the thread with Julian about 4 ways to generate procs dynamically

Although I guess in that case it was mostly foo-$suffix, which is usually OK

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