9 ms·
>That makes no sense, $1, $2, and $3 are different parameters. >Using your example, |> `${$3.id}: ${$1.friendlyName} ${$2.url}` >makes absolutely no sense
by ubertaco 4y ago
>That makes no sense, $1, $2, and $3 are different parameters.
>Using your example,
|> `${$3.id}: ${$1.friendlyName} ${$2.url}`
>makes absolutely no sense.
That's not what I was saying. I was saying that using `$1`, `$2`, and `$3` _would be different parameters, which would be good at helping disambiguate_.
That would enable this, from my example:
|> `${$1.id}: ${$1.friendlyName} ${$1.url}`
while also enabling something like this:
|> `$1.indexOf($2)`
...whereas just sticking with the single `%` means you _can't_ disambiguate, and that if they instead try to allow disambiguation by deciding that the first `%` is `$1`, and the second `%` is `$2` (and so on), then now you can't use the template-string example I gave.
Having unique "magic scope variables" at least allows you the flexibility to handle non-unary use-cases.
Either way, this is another case of "every lexer/parser has to be riddled with special cases" to handle "is this `%` a fancy-pipeline-identifier, or is it an operator?"
- masklinn 4y ago> That would enable this, from my example: So the same thing except more verbose. > while also enabling something like this: Enable for what? A pipeline threads a value through a sequence of operation, there is no second parameter. > ...whereas just sticking with the single `%` means you _can't_ disambiguate Which doesn't matter because there is nothing to disambiguate. > Having unique "magic scope variables" at least allows you the flexibility to handle non-unary use-cases. Which do not and can not exist. And even if they did (which, again, they don't), you could do exactly what Clojure does with its lambda shorthand: %1, %2, %3, %4. > Either way, this is another case of "every lexer/parser has to be riddled with special cases" to handle "is this `%` a fancy-pipeline-identifier, or is it an operator?" There is no special case, having the same character be a unary and binary operator is a standard feature of pretty much every parser. Javascript certainly has multiple, as well as operators which are both pre and post-fix.