stage-0
andstage-4
features.
TOC:
- Relationshiops
- String.prototype.at
- Reflect.isCallable
- Reflect.isConstructor
- Additional metaproperties
- Function Bind Syntax
- Do Expressions
- 64-Bit Integer Operations
- Method Parameter Decorators
- Function Expression Decorators
- Zones
- Explicit syntactic opt-in for Tail Calls
- Object enumerables
- Unicode property escapes in RE
STAGE 0:
#Defensible Classes
// const class
const class Point {
constructor(x, y) {
public getX() { return x; }
public getY() { return y; }
}
toString() {
return `<${this.getX()}, ${this.getY()}>`;
}
}
x @ r // The object x is in the r relationship with what value?
x @ r = y; // Store that x is in the r relationship with value y.
'abc\uD834\uDF06def'.at(3), '\uD834\uDF06'
Reflect.isCallable(argument);
Reflect.isConstructor(argument)
function.callee; // function object that is currently being evaluated by the running execution context.
function.count; // number of arguments pass to the function.
function.arguments; // array containing the actual arguments passed to the function.
// :: which performs this binding and method extraction.
Promise.resolve(123).then(::console.log);
// do all the flexible things you can do with statements while still producing a useful result and plugging that back into an expression context.
x = do { let t = f(); t * t + 1 };
// return the high 32 bit part of the 64 bit addition of (hi0, lo0) and (hi1, lo1)
Math.iaddh(lo0, hi0, lo1, hi1);
// return the high 32 bit part of the 64 bit subtraction of (hi0, lo0) and (hi1, lo1)
Math.isubh(lo0, hi0, lo1, hi1);
// return the high 32 bit part of the signed 64 bit product of the 32 bit numbers a and b
Math.imulh(a, b);
// return the high 32 bit part of the unsigned 64 bit product of the 32 bit numbers a and b
Math.umulh(a, b);
//decorators that operate on method and constructor parameters.
class MyComponent {
refresh(@lastRefreshTime timeStamp) { … }
}
export function lastRefreshTime(...) {
// at minimum, the arguments of this function should contain:
// - reference to owner of the parameter (the method)
// - parameter index
// - parameter name
// - is parameter a rest parameter?
// store parameter metadata using the same storage mechanism
// as the one used for methods
}
scheduleForFrequentReexecution(@memoize function(value) {
value++
});
export function memoize(...) {
// at minimum, the arguments of this function should contain:
// - reference to the decorated function expression
// - arguments passed into the memoize function (if any)
// wrap the decorated function expression memoization implementation and return it
}
//a primitive for context propagation across multiple logically-connected async operations
class Zone {
constructor({ name, parent });
name;
get parent();
fork({ name });
run(callback);
wrap(callback);
static get current();
}
const loadZone = Zone.current.fork({ name: "loading zone" });
window.onload = loadZone.wrap(e => { ... });
let factorial = (n, acc = 1) =>
n == 1 ? acc
: continue factorial(n - 1, acc * n);
Object.enumerableKeys(obj); // Ordered list of keys.
Object.enumerableValues(obj); // Ordered list of Values.
Object.enumerableEntries(obj); //Ordered list of key value pairs.
const regexGreekSymbol = /\p{Script=Greek}/u;
regexGreekSymbol.test('π');