This is the formal specification for a proposed "smart pipe operator" |>
in JavaScript. It modifies the original ECMAScript specification with several new or revised clauses. The Core Proposal is at Stage 0. Additional Features are given as annexes; none of the Additional Features are at a TC39-proposal stage. See the proposal's explainer for the proposal's background, motivation, usage examples, explanation, and information on planned add-on proposals.
This section is a wholly new sub-clause of the original Lexical Environments clause. It is forward compatible with
The topic binding of a #
to one value of any
A topic-binding environment is a
The only Lexical Environments that are topic-binding environments are declarative environments that are associated with
There is also one syntax nonterminal that instantiates topic-binding environments with provided topic values of any
All other Lexical Environments do not establish any topic bindings; in particular, object and global environments are never topic-binding environments.
In addition, several syntax nonterminals associated with Lexical Environments are associated with #
, except where the
Any use of the
Also note that the other nonterminals of the productions above do not have similar topic-forbidding
Other syntax nonterminals, even if they similarly define inner program scopes that contain nested
These topic-permitting nonterminals’ Lexical Environments do not establish topic bindings of their own; therefore, at runtime, topic references that are contained within their scopes would be evaluated to the value of their outer environments' topic bindings. In addition, their inner topic references are visible to Contains and they are subject to the same
This section augments the original Environment Records clause. It is forward compatible with
Method | Purpose |
---|---|
HasTopicBinding() |
Determine the status of an |
This section augments the original Declarative Environment Records clause. It is forward compatible with
Each declarative
Declarative Environment Records have the additional state fields listed in
Method | Value | Purpose |
---|---|---|
[[TopicBindingStatus]] |
|
If [[TopicBindingStatus]]'s value is # ) to values. If the value is |
[[TopicValues]] |
|
If the value of [[TopicBindingStatus]] is # within its program scope). Otherwise, the value of [[TopicValues]] is |
[[TopicValues]] is a
Declarative Environment Records support all of the abstract methods of Environment Records listed in
Method | Purpose |
---|---|
BindTopicValues(V) |
Establish the immutable |
BindTopicValues() accepts a
The behaviour of the concrete and additional specification methods for declarative Environment Records is defined by the following algorithms.
This section is a wholly new sub-clause of the original Declarative Environment Records clause.
The concrete
This section is a wholly new sub-clause of the original Declarative Environment Records clause. It is forward compatible with
The method BindTopicValues for declarative Environment Records is guaranteed to be called only when the Environment Records do not yet have established
This section is a wholly new sub-clause of the original Object Environment Records clause.
Regular object Environment Records never have
This section is a wholly new sub-clause of the original Global Environment Records clause.
Global Environment Records never have
This section augments the original Punctuators clause. It is forward compatible with
This section augments the original Primary Expression clause. It is forward compatible with
This section is a wholly new sub-clause to be inserted between the original this
Keyword clause and the original Identifier Reference clause. It is forward compatible with
The topic reference, which is the token #
, is a nullary operator that evaluates to the value of the current #
is not actually an
The concept of lexical
GetTopicEnvironment finds the #
). That is, it finds the running execution
When the abstract operation GetTopicEnvironment is called the following steps are performed:
The loop in step 2 will always terminate because the
This is because how, in general, syntax nonterminals that define top-level scopes (such as #
. Any use of the
GetTopicValues gets the values of the
When the abstract operation
This section is an augmentation of the original EvaluateCall clause such that its arguments parameter may be a
The abstract operation EvaluateCall takes as arguments a value func, a value ref, a
This section is a wholly new sub-clause to be inserted between the original Conditional Operator (?
:
) clause and the original Assignment Operators clause. It is forward compatible with
When processing an instance of the production
This section is a wholly new sub-clause. It is forward compatible with
These early errors prohibit any pipeline input expressions or pipeline step expressions from
#
is This third
With parameter symbol.
This section is a wholly new sub-clause. It is forward compatible with
#
, return This section is a wholly new sub-clause.
This section is not strictly required for the core proposal, but it would be commonly used by both
This section is a wholly new sub-clause. It is forward compatible with
This abstract operation constructs, instantiates, then returns a new declarative
TopicPipelineInstantiation is performed as follows using arguments env and topicValues.
With parameter inputValues.
This section augments the original Assignment Operators clause. It is forward compatible with
This section augments the original Iteration Statements clause. It is forward compatible with
#
is Syntax nonterminals that establish new lexical bindings within new inner program scopes, including iteration statements, may not contain a #
. However, such
with
statementThis section augments the original with
Statement, Static Semantics: Early Errors clause. It is forward compatible with
#
is Syntax nonterminals that establish new lexical bindings within new inner program scopes, including #
. However, such
try
statementThis section augments the original try
Statement, Static Semantics: Early Errors clause. It is forward compatible with
#
is Syntax nonterminals that establish new lexical bindings within new inner program scopes, including #
. However, such
Furthermore, the try
and finally
blocks themselves (
This section augments the original Function Definitions, Static Semantics: Early Errors clause. It is forward compatible with
#
is Arrow functions' #
, as long as
Along with #
.
With parameter symbol.
This section augments the original Arrow Functions, Static Semantics: Contains clause. It is forward compatible with
super
or this
super
, this
, or #
, return new.target
, this
, and super
this
, super
, and #
usage within an This section augments the original Scripts, Static Semantics: Early Errors clause. It is forward compatible with
#
is In general, a top-level program scope, including #
. However, such
This section augments the original Modules, Static Semantics: Early Errors clause. It is forward compatible with
#
is In general, a top-level program scope, including #
. However, such
Not at Stage 0.
This annex specifies additional ECMAScript language syntax and semantics for bare new
.
See the explainer document, § Motivation, Additional Feature BC for information on this feature's motivation.
new
OperatorThis section is an augmentation of the original EvaluateNew clause such that its arguments parameter may be a
The abstract operation EvaluateNew with arguments constructExpr, and arguments performs the following steps:
This section augments the
This section augments the
With parameter inputValues.
This section augments the
Not at Stage 0.
This annex specifies additional ECMAScript language syntax and semantics for bare awaited function calls. It augments the await
.
See the explainer document, § Motivation, Additional Feature BA for information on this feature's motivation.
This section augments the
This section augments the
With parameter inputValues.
This section augments the
This algorithm is an altered version of the algorithm of
Not at Stage 0.
This annex specifies additional ECMAScript language syntax and semantics for pipeline functions. It augments the
See the explainer document, § Motivation, Additional Feature BP for information on this feature's motivation.
This section augments the
This section augments the
#
is With parameter symbol.
This section augments the
#
, return With parameter inputValues.
Not at Stage 0.
This annex specifies additional ECMAScript language syntax and semantics for pipeline functions. It augments the +>
. This new unary operator creates arrow functions with an implicit parameter inputted into a pipeline. The operator brings much power: it enables terse method extraction, terse partial application of functions/expressions (into unary functions), and terse composition of functions/expressions.
[TODO: This annex is unfinished. Async pipeline functions are yet to be added.]
See the explainer document, § Motivation, Additional Feature PF for information on this feature's motivation.
|
|
|
|
|
|
|
|
|
|
|
|
This annex uses a new token +>
, but this token is merely an illustrative placeholder to avoid premature bikeshedding discussion. The actual operator ideally would communicate its status as a combination of =>
and |>
. Example replacements of +>
include ->
|>
operator with the |
rotated sideways and resembles the =>
operator but with a narrower arrow body) and =|
=>
and |>
with the >
removed).
This section further augments the
This section would be a wholly new sub-clause to the
With parameter symbol.
super
or this
super
, this
, or #
, return new.target
, this
, super
, and #
usage within a Because the formal parameter lists of pipeline functions are their pipelines themselves, the ExpectedArgumentCount of pipeline functions is implicitly specified by the
With parameters iteratorRecord and environment.
This
However, pipeline functions do not use IteratorBindingInitialization to create parameter bindings; instead, they pass their arguments directly into
With parameters functionObject and
Not at Stage 0.
This annex specifies additional ECMAScript language syntax and semantics for n-ary smart pipelines and multiple lexical topics. It augments the inputList |> …
and … |> stepList |> …
, an additional ##
, a ###
, a ...
, and an argument-
See the explainer document, § Motivation, Additional Feature NP for information on this feature's motivation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Syntax Error: Pipeline head inputs 0 () into a following step that expects 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Syntax Error: Pipeline head inputs 2 (a, b) into following step that expects 1 |
|
Syntax Error: f in (# * b, f) binds |
|
Syntax Error: Pipeline head inputs 2 (a, b) into following step that expects 1 |
|
Syntax Error: Pipeline head inputs 1 a into following step that expects 2 |
|
Syntax Error: Pipeline head inputs 0 () into following step that expects 1 |
|
Syntax Error: Pipeline head inputs 2 (a, b) into following step that expects 1 |
|
Syntax Error: Pipeline terminates with a 2-ary pipeline step but must terminate with a unary pipeline step. |
This section further augments the
The topic binding of a #
to one value of any #
, ##
, ###
, and ...
, each to a respective topic value of any #
is termed the primary topic reference, ##
is termed the secondary topic reference, and ###
is termed the tertiary topic reference; together, they form the ...
alone forms the s as the values that the lexical context is "about".
A topic-binding environment is a
In addition, several syntax productions associated with Lexical Environments are associated with #
, ##
, ###
, or ...
, except where that iss are within a
This section augments the
Method | Purpose |
---|---|
HasTopicBinding() |
Determine the status of an # , ## , ### , and ... ). Return |
This section adds onto the
Method | Value | Purpose |
---|---|---|
[[TopicBindingStatus]] |
|
If [[TopicBindingStatus]]'s value is # , ## , ### , and ... ) to values. If the value is |
[[TopicValues]] |
Any | |
If the value of [[TopicBindingStatus]] is # , ## , and ### within its program scope). Otherwise, the value of [[TopicValues]] is |
[[RestTopicStartIndex]] |
|
If the value of [[TopicBindingStatus]] is ... ; if so, this index must be an |
Declarative Environment Records support all of the abstract methods of Environment Records listed in
Method | Purpose |
---|---|
BindTopicValues(V, VRestStartIndex) |
Establish the immutable |
The behaviour of the concrete and additional specification methods for declarative Environment Records is defined by the following algorithms.
This section augments the
The method BindTopicValues for declarative Environment Records is guaranteed to be called only when the Environment Records do not yet have established
This section adds onto the
This section adds onto the
This section augments the
The ...
is not itself a
This section is a wholly new sub-clause in addition to the augmentations of the core proposal.
With parameter topicIndex.
This abstract operation constructs, instantiates, then returns a new declarative
This section is a wholly new sub-clause in addition to the augmentations of the core proposal.
The ...
is not itself evaluated as a
This section augments the
The ...
is not itself evaluated as a
With parameters array and nextIndex.
This section is a wholly new sub-clause of the original Argument Lists clause.
This section is a wholly new sub-clause of the original Argument Lists clause.
If preceding is
This section augments the original ArgumentListEvaluation clause.
This section augments the
When processing an instance of the production
This section augments the
#
is ...
is The production
This section is a wholly new sub-clause of the
This section is a wholly new sub-clause of the
With parameter symbol.
This section augments the
#
This section augments the
###
, then return ##
, then return #
, then return The production
This section is a wholly new sub-clause in addition to the sub-clauses of the core proposal that extends the
With parameter inputValues.
This section augments the
This section augments the
and topicValuestopicValues, and restTopicStartIndex.
...
will not be bound to anything. Otherwise, This section augments the
This section adds onto the
#
is Syntax nonterminals that establish new lexical bindings within new inner program scopes, including iteration statements, may not contain a #
#
, ##
, or ###
) or a ...
). However, such
with
statementThis section adds onto the
#
is Syntax nonterminals that establish new lexical bindings within new inner program scopes, including #
#
, ##
, or ###
) or a ...
). However, such
try
statementThis section adds onto the
#
is Syntax nonterminals that establish new lexical bindings within new inner program scopes, including #
#
, ##
, or ###
) or a ...
). However, such
This section adds onto the
#
is Arrow functions' the a TopicExpression (#
#
, ##
, or ###
) or a RestTopicReference (...
), as long as
With parameter symbol.
This section adds onto the
super
, this
, #
new.target
, this
, super
, #
#
, ##
, or ###
), and ...
) usage within an This section adds onto the
#
is In general, a top-level program scope, including #
#
, ##
, or ###
) or a ...
). However, such
This section adds onto the
#
is In general, a top-level program scope, including #
. However, such
try
StatementsNot at Stage 0.
try
statementThis section adds onto the catch
binding.
The try
statement encloses a block of code or a pipeline in which an exceptional condition can occur, such as a runtime error or a throw
statement. The catch
clause provides the exception-handling code. When a catch clause with a
This section augments the
If the augmentations of
#
is If the augmentations of
#
is Syntax nonterminals that establish new lexical bindings within new inner program scopes, including #
#
, ##
, or ###
) or a ...
). However, such
The following early errors are inserted only if the augmentations of
With parameter symbol.
This section is a wholly new sub-clause.
#
, return With parameter labelSet.
This section augments the original try
Statement, Static Semantics: ContainsDuplicateLabels clause.
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
With parameter labelSet.
This section augments the original try
Statement, Static Semantics: ContainsUndefinedBreakTarget clause.
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
With parameters iterationSet and labelSet.
This section augments the original try
Statement, Static Semantics: ContainsUndefinedContinueTarget clause.
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
This section augments the original try
Statement, Static Semantics: VarDeclaredNames clause.
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
This section augments the original try
Statement, Static Semantics: VarScopedDeclarations clause.
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
If the augmentations of
This section augments the original CatchClauseEvaluation clause.
With parameter thrownValue.
This section augments the original try
Statement, Static Semantics: Evaluation clause.
© 2020 J. S. Choi, Ecma International
All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.