Skip to content

Commit

Permalink
Template expression rationale
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton committed Jul 17, 2018
1 parent fc47d8f commit 143611e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ However, there are several of limitations with these approaches:

* `bind` can only fix the leading arguments of a function.
* `bind` requires you explicitly specify the `this` receiver.
* You cannot easily use `bind` with a template expression or tagged template expression.
* Arrow functions can be cumbersome when paired with the [pipeline proposal](https://github.com/gilbert/es-pipeline-operator):
* Need to write `|> _ =>` for each step in the pipeline.
* Unclear as to which stack frame we are in for the call to `clamp`. This can affect available stack space and
Expand All @@ -62,8 +63,11 @@ let newScore = player.score
|> clamp(0, 100, ?); // shallow stack, the pipe to `clamp` is the same frame as the pipe to `add`.

// partial template strings
const getHello = `Hello, ${?}!`;
const helloBob = getHello("Bob"); // "Hello, Bob!"
const Diagnostics = {
unexpected_token: `Unexpected token: ${?}`,
name_not_found: `'${?}' not found.`
};
Diagnostics.name_not_found("foo"); // "'foo' not found."
```
# Syntax
Expand Down

0 comments on commit 143611e

Please sign in to comment.