diff --git a/docs/parameterized-function-expressions.md b/docs/explicit-type-parameter-instantiation.md similarity index 93% rename from docs/parameterized-function-expressions.md rename to docs/explicit-type-parameter-instantiation.md index 4e57305..416fc42 100644 --- a/docs/parameterized-function-expressions.md +++ b/docs/explicit-type-parameter-instantiation.md @@ -1,4 +1,4 @@ -# Parameterized function expressions +# Explicit type parameter instantiation ## Summary @@ -80,19 +80,19 @@ Signals.playerTookDamageSignal = createSignal() We propose allowing the following: ```lua +-- Saving `f<>` as a variable to called later +local a = f<> + -- Parameterized function call as statement f<>() -- Parameterized function call as expression -local a = f<>() +local b = f<>() -- Calling through index -local b = t.f<>() -local c = t:f<>() -local d = t["f"]<>() - --- Saving `f<>` as a variable to called later -local e = f<> +local c = t.f<>() +local d = t:f<>() +local e = t["f"]<>() ``` For parsing, we will do this by extending `var` to allow `prefixexp '<<' TypeList '>>'`. This will bind the prefixexp equivalent to the substitution of the type parameters. That is to say... @@ -146,9 +146,9 @@ local moneyBinding = React.createBinding.() local moneyBinding = React.createBinding:() ``` -The downside of these is that they blur the lines between runtime and static, in the sense that `React.createBinding.` starts out as a runtime concept, followed by the purely static ``. As for `:`, it carries the baggage of `x:y()` which will perform a runtime mutation of the function call in the form of adding on `self`. +The downside of these is that they blur the lines between runtime and static, in the sense that `React.createBinding.` starts out as a runtime concept, followed by the purely static ``. As for `:`, it carries the baggage of `x:y()` carrying the interesting behavior of adding `self` to the call, which it does not do here. -There is also not necessarily a reason that we have to provide symmetrical operators, so something like `f!T, U()` is reasonably parseable, but is not obviously better. +There is also not necessarily a reason that we have to provide symmetrical operators, so something like `f!T, U()` is reasonably parseable, but is not obviously better and is even more unlike any other language's syntax. Ultimately, this RFC chooses `<>` as a least worst option that is fluid to type, easy to read, and easy to remember.