This is the formal specification for a proposed "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. 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.
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 value of any
All other Lexical Environments do not establish any topic binding; 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
This section augments the original Environment Records clause.
Method | Purpose |
---|---|
HasTopicBinding() |
Determine the status of an |
This section augments the original Declarative Environment Records clause.
Each declarative
Declarative Environment Records have the additional state fields listed in
Method | Value | Purpose |
---|---|---|
[[TopicBindingStatus]] |
|
If [[TopicBindingStatus]]'s value is # ). If the value is |
[[TopicValue]] |
any | |
If the value of [[TopicBindingStatus]] is # within its program scope). Otherwise, the value of [[TopicValue]] is |
Declarative Environment Records support all of the abstract methods of Environment Records listed in
Method | Purpose |
---|---|
BindTopicValue(V) |
Establish the immutable |
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.
The method BindTopicValue 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 a
This section augments the original Punctuators clause.
This section augments the original Primary Expression clause.
This section is a wholly new sub-clause to be inserted between the original this
Keyword clause and the original Identifier Reference clause.
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
GetTopicValue gets the value of the
When the abstract operation
This section is a wholly new sub-clause to be inserted between the original Conditional Operator (?
:
) clause and the original Assignment Operators clause.
This section is a wholly new sub-clause.
#
is This section is a wholly new sub-clause.
This abstract operation constructs, instantiates, then returns a new declarative
TopicPipelineInstantiation is performed as follows using arguments env and topicValue.
With parameter inputValue.
This section augments the original Assignment Operators clause.
This section augments the original Function Definitions, Static Semantics: Early Errors clause.
#
is With parameter symbol.
This section augments the original Arrow Functions, Static Semantics: Contains clause.
super
or this
super
, this
, or #
, return #
, 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 not planned to be removed by other additional syntax.
#
is In general, a top-level program scope, including #
. However, such
This section augments the original Modules, Static Semantics: Early Errors clause. It is not planned to be removed by other additional syntax.
#
is In general, a top-level program scope, including #
. However, such
This will be introduced as its own separate proposal but is included here for reference.
This annex specifies additional ECMAScript language syntax and semantics for
optional pipelines. It augments the
See the explainer document, § Motivation, Additional Feature OP for information on this feature's motivation.
The rest of this additional proposal spec is WIP.© 2020 Michal Srb (original by 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 http://www.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.