Open littledan opened 5 years ago
I personally think @[expressionLike]
is okay. Other candidates might be something like identifier!
/identifier(args)!
, @@identifier
/@@identifier(args)
, or something else entirely.
One way to think about it might be to consider what the language would've looked like if all reserved used such syntax:
@[class] Point {
constructor(x, y) {
@[this].x = x
@[this].y = y
}
}
@[function] add(a, b) {
@[return] a + b
}
@[async] @[generator] @[function] foo(sequence) {
@[for await] (@[const] x @[of] sequence) {
@[yield] 12
}
}
class! Point {
constructor(x, y) {
this!.x = x
this!.y = y
}
}
function! add(a, b) {
return! a + b
}
async! generator! function! foo(sequence) {
for! await! (const! x of! sequence) {
yield! 12
}
}
Although special syntax does make me wonder of the feasibility of macros with some builtin ones that might not be implementable in userland (e.g. tailcall).
I like @[expressionLike]
, though would be okay with variations on the theme:
@{expressionLike}
<@expressionLike>
[@expressionLike]
!@expressionLike
I don't like any of those better than the proposed.
In my very humble opinion @[expressionLike]
reminds the destructuring and I prefer other form as !@expresionlike
.
If we go with the static/built-in decorators proposal, we may just be able to use @foo
for most of the use cases in this README. I am meaning to update this document, and just haven't gotten around to it yet.
Good news. Don't worry, you have a lot of work with a lot of proposals.
The current explainer uses
@[expressionLike]
. What do you think the syntax should be?