jashkenas / jashkenas/coffeescript
Request: Support Svelte JS labels
- Dominant language
- CoffeeScript
- Stars
- 16.6k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
There was no need for JS labels before, but Svelte found a good use for the syntax. Currently it can only be passed with backticks, but it's very limited and unwieldy.
```coffee
`$: {`
foo 'hi' # must not properly indent
`}`
```
All other fail
```coffee
`$:` foo 'hi'
# produces ({ $: foo 'hi' })
`$:`
foo 'hi'
# erroneous
# $:;
# foo('hi');
`$: {` foo 'hi' `}`
# won't compile
```
Simplest and very Coffee solution would be to spell out the syntax name, but honestly whatevs, whatever names you have left reserved or can reappropriate such as `case` outside of `switch`.
```coffee
label $: foo 'hi' # or = or space
label $
foo 'hi'
foo 'hi'
```
It's true this label use isn't idiomatic and that it's a solitary kinda-framework example. But, it is actually using the standard syntax, and its unidiomatic use became innovative, because unlike before, it's actually a good use. Past addition of JSX could be considered similar, and a good place for it in documentation (since it is after all a rare good example of Js labels, so it's mostly about Svelte).
In my very humble general opinion here, Coffeescript should adapt here and there because Javascript is a hackable text based language for better and for worse. Otherwise is excessively conservative and necessarily keeps the bad part of Js (Js is what it is), while losing the better part (it's hackable, here for the better). Good guideline for when is enough of offshoots should include standard syntax when it's a good use even if an unconventional one. (So-so unconvencional actually, it's not like Svelte is so unheard of.)
Contributor guide
Research direction
Start by reproducing the CoffeeScript examples in the issue and reviewing how the compiler currently parses backtick-wrapped labels. No file or test entry point is named, and the proposed `label` syntax has several alternatives; clarify the accepted syntax first. Done means the chosen Svelte label form compiles correctly and is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- coffeescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100