| 11 Dec 2025 |
Charles | if i were designing a language from scratch and i wanted support for more or less arbitrary identifiers, i would have two kinds of identifiers:
- literal identifiers, like
foo, foo_bar, _foo123, etc; XID_Start followed by >=0 XID_Continue
- string identifiers, like
i"..." to use an arbitrary string of characters and escape sequences to construct an identifier
| 21:13:16 |
Charles | so a-1 would parse as identifer a minus literal 1, not an identifier a-1 | 21:14:18 |
Rutile (Commentator2.0) feel free to ping | In reply to @charles:computer.surgery
if i were designing a language from scratch and i wanted support for more or less arbitrary identifiers, i would have two kinds of identifiers:
- literal identifiers, like
foo, foo_bar, _foo123, etc; XID_Start followed by >=0 XID_Continue
- string identifiers, like
i"..." to use an arbitrary string of characters and escape sequences to construct an identifier
This honestly sounds quire reasonable | 21:14:27 |
Charles | if you want a-1 as an identifier you'd write i"a-1" instead | 21:14:32 |
Charles | this way you get the convenience of literal identifiers for the common cases, - behaves in an obvious way, and i"..." is an "escape hatch" for other cases like i"1Password" or whatever | 21:16:19 |
helle (just a stray cat girl) | so in addition to the formal form, I would always ask, "okay, so you are now teaching someone who just finished introduction to programming and introduction to Java, how would you explain this" | 21:17:26 |
Charles | also i would probably want to define e.g. a and i"a" as syntactically equivalent | 21:17:39 |
Charles | "if you want arbitrary characters in your identifier then you can wrap it in i"..."" | 21:18:12 |
helle (just a stray cat girl) | yeah, and when does it become "arbitrary"? | 21:18:26 |