Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial: Fix markdown syntax #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions ES7MetaProps.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,43 @@ However, recently ES6 added the syntatic concept of a *MetaProperty*. Syntactic
ES6 defined only one *MetaProperty*, `new.target`. However, this establishes a syntactic pattern that could be applied for accessing other contextually variable run-time values. For ES7 we should review the set of such values that we know about and considering adding additional meta properties for accessing them.
### Candidate Meta Properties

####`function.callee` -- The currently running function
#####Value and Context
#### `function.callee`
The currently running function

##### Value and Context
The value of `function.callee` is the function object that is currently being evaluated by the running execution context. It is *not* lexically scoped like `this`, `super` or `new.target`. Its value may be an Arrow Function.

Referencing `function.callee` outside of function code is a Syntax Error.

#####Use Cases
##### Use Cases
Anonymous functions, arrow functions, and concise methods with non-identifier property names sometimes need to recursively refer to themselves. Prior to ES5 the currently executing function object was available via `arguments.callee` but that is now unavailable in strict mode functions. In addition, within arrow functions, `argument` is lexically scoped to the closest containing non-arrow function.

####`function.count` -- The actual argument count
#####Value and Context
#### `function.count`
The actual argument count

##### Value and Context
The value of `function.count` is the actual number of arguments pass to the function that is currently being evaluated by the running execution context. It is *not* lexically scoped like `arguments` so it can report the number of arguments passed to an Arrow Function.

Referencing `function.count` outside of function code is a Syntax Error.

#####Use Cases
##### Use Cases
Even with the availability of parameter default values and rest parameters it is sometimes useful to know the actual number of arguments passed to a function invocation. For example, to help resolve argument overloads. The only currently available way to get the actual argument count that will work for any function is to declare the function with a single rest parameter, for example:
```es6
(...args)=>console.log(args.length)
```
The use of this technique precludes use of a more meaningful parameter signature and forces instantiation of an array containing the argument values even if the only information needed is the argument count.

####`function.arguments` -- The actual argument list
#####Value and Context
#### `function.arguments`
The actual argument list

##### Value and Context
The value of `function.arguments` is an array containing the actual arguments passed to the function that is currently being evaluated by the running execution context. It is *not* lexically scoped like `arguments` so it can provide the actual arguments passed to an Arrow Function. It is essentially the same as the value that is assigned to `args` for a parameter list of the form `(...args)`.

Each time `function.arguments` is evaluated it returns a fresh array.

Referencing `function.arguments` outside of function code is a Syntax Error.

#####Use Cases
##### Use Cases
`function.arguments` is essentially a replacement for the legacy `arguments` object that doesn't carry any of the baggage of `arguments` and which can be used with all function forms including Arrow Functions and in all modes. Uses include declaring a function with a meaningful parameter signature while still having the original arguments available if an overload conditions requires delegation of the arguments to another function..


Expand Down
10 changes: 6 additions & 4 deletions Generator metaproperty.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ In the above example, the argument to the `next` method normally supplies the v
This proposal provides an alternative way to access the `next` parameter that works on the first and all subsequent invocations of a generator's `next` method.
### The Proposal

###A new meta-property: `function.sent`
#####Value and Context
#### A new meta-property: `function.sent`

##### Value and Context
The value of `function.sent` within the body of a Generator Function is the value passed to the generator by the `next` method that most recently resumed execution of the generator. In particular, referencing `function.sent` prior to the first evaluation of a `yield` operator returns the argument value passed by the `next` call that started evaluation of the *GeneratorBody*.

`function.sent` can appear anywhere a *YieldExpress* would be legal. Referencing `function.sent` outside of a *GeneratorBody* is a Syntax Error.
#####Usage Example

##### Usage Example
Here is how the above example might be rewritten using `function.sent`
```js
function *adder(total=0) {
Expand All @@ -61,7 +63,7 @@ let last=tally.next("done");
console.log(last.value); //0.3
```

###Specification Updates
### Specification Updates
The following are deltas to the ECMAScript 2015 Language Specification
#### 8.3 Execution Contests
The following row is added to **Table 24**:<br>
Expand Down
12 changes: 6 additions & 6 deletions dcltomethod.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ However, cloning a function creates other complications. Is the clone a deep or
The answer used in the ES6 draft version of `toMethod` was to perform a shallow clone of the function excluding all own properties except for `length`. If any other properties needed to be included in the clone (either shallowly or deeply) it was up to caller to `toMethod` to take care of that copying after `toMethod` returned the clone to it. For this reason, the ES6 draft `toMethod` was best thought of as a primitive that was intended to be primarily used by mix-in libraries or other abstractions over objects. Such libraries would have needed to establish their own policies for dealing with the cloning issue and for dealing with various kinds of exotic function objects.

Ultimately, TC39 decided that `toMethod` was too complex and error-prone.
### Declarative Is Better
### Declarative Is Better
As shown in the examples above, defining methods that reference `super` properties in class declarations is simple and straightforward. This is also true for object literals such as:
```js
let dog = {
Expand Down Expand Up @@ -110,7 +110,7 @@ aPusher mixin {
}
};
```
###A Declarative Solution
### A Declarative Solution
In this solution, `mixin` is a contextual keyword that is the first token of a high precedence left-associative postfix operator. The second part of a `mixin`operator has the syntax of an object literal and all of the normal property definition forms are allowed within it except for `__proto__:`. Note that the object literal is a integral part of the `mixin` postfix operator operator, not a separate sub expression. We call the value that the `mixin` operator is applied to the "augmented object".

A simplified syntactic description of the `mixin` operator is:
Expand All @@ -122,7 +122,7 @@ The semantics are almost exactly the same as a regular object literal except tha
Any methods within the `ObjectLiteral` that need a [[HomeObject]] binding are created with the augment object as their [[HomeObject]] value. No method cloning is perform and a method with the "wrong" or `undefined` [[HomeObject]] never exists.

**Note that it is a very important characteristic that this proposal that `mixin` is an operator**, rather than a function such as `Object.mixin` which was considered for ES6. Use of an operator allows the new methods to be initially instantiated using the correct [[HomeObject]] values. All function based approaches require initially instantiating functions with the wrong [[HomeObject]] values and this leads to the need to clone the functions.
####But What If You Need Imperative Mixins?
#### But What If You Need Imperative Mixins?
The `mixin` operator solves the [[HomeObject]] binding problem by always defining the mixed-in methods at one place in a program so that the augmented object is available when the method function objects are instantiated. But what if you need to apply a mixin at many different places in a program? Just use procedural abstraction:
```es6
//someMixin.js
Expand All @@ -139,7 +139,7 @@ let myObj = someMixin(new MyClass());
someFunct(someMixin(anotherObj));
//...
```
####Augmenting Classes
#### Augmenting Classes
The mixin operator can be applied to any object, including class objects and constructor functions:
```es6
class C extends B{
Expand Down Expand Up @@ -177,9 +177,9 @@ C mixin class {
static sm2() {super.sm2()};//[[HomeObject]] is C
}
```
###None Goals
### Non-Goals
This proposal is not intended to be a replacement for higher level class composition abstractions such as Traits. Instead it provides the essential primitive language capabilities which combined with procedural or object abstraction capabilities can be used to define such higher level compositional abstractions.
###BNF
### BNF

Here is the proposed BNF for this extension.

Expand Down