TC39 meeting, January 25-28 2021


This meeting, the focus was in brand checking. We had a few proposals looking at the question of “how do we know what this really is”. In JavaScript, instanceof is spoofable. A non spoofable check is refered to as a brand. A common example is Array.isArray. We discussed brand checks in a few forms, including class brand checks, using private fields as a way of determining a brand, Type.isType as a generic brand check, and brand checks on template strings.

On the ergonomics side, do expressions were raised once more. They now take two forms: Sync and async:

Sync do:

let x = do {
  let tmp = f();
  tmp * tmp + 1
};

Async Do:

async do {
  await readFile('in.txt');
  let query = await ask('???');
  // etc
}

Finally, I presented a proposal to introduce deferred module evaluation. This would be a standard form of “sync lazy module evaluation”. Unlike dynamic import, the module is fetched eagerly, but it’s evaluation is deferred until it is used. The conversations is quite interesting and may lead to an interesting concept that we could adopt later on, once we have moved to ESMs.

Needs minor change:

None.

Keep an eye on…

  • async do expressions
  • do expressions
  • Brand checking
  • Deferred module evaluation.

Normative Spec Changes


Runtime Semantics for MemberExpression do not conform to web reality

  • Notes
  • PR
  • Summary: Member Expressions have an extra check when they are accessed. This has not been implemented according to spec by any browser due to performance concerns about this extra check. The goal of this change was to update the spec to reflect browser behavior.
  • Impact on SM: None
  • Outcome: Consensus. Add tests and land.

Proposals Seeking Advancement to Stage 4


Intl.DateTimeFormat.prototype.formatRange

  • Notes
  • Proposal Link
  • Spec
  • PR
  • Slides
  • Summary: It’s common for websites to display date intervals or date ranges to show the span of an event, such as a hotel reservation, the billing period of a service, or other similar uses. In order to implement this, websites often use localization libraries, such as Google Closure, to format the date range, or they may simply resort to formatting both dates independently.
  • Impact on SM: Completed implementation,
  • Outcome: Advanced to stage 4.

Proposals Seeking Advancement to Stage 3


JSON modules for Stage 3

  • Notes
  • Slides
  • Proposal Link
  • Summary: Introduces importable JSON modules that require the import syntax changes above. Whereas the above proposal is about the syntax, this proposal represents the module loading mechanism. The discussion centered around how developers would expect the import to behave, whether or not they would expect a singleton or a copy, and if they would want that copy to be mutable. There were arguments for both sides.
  • Impact on SM: Requires implementation,
  • Outcome: Advanced to Stage 3.

Array.isTemplateObject

  • Notes
  • Proposal Link
  • Slides
  • Summary: Provides a way for template tag functions to tell whether they were called with a template string bundle. This woul allow for a way to distinguishh a string coming from a developer, as opposed to a potentially untrusted string.
  • Impact on SM: Mostly implemented,
  • Outcome: No consensus for advancement, requires further iteration. Solution is incomplete: This is making an assumption that all evals that are reachable in the object graph are all suppressed and that there’s no objects created by an attacker within the object graph, but this doesn’t take into account threat models that members are concerned about

Class static Initialization Blocks

  • Notes
  • Proposal Link
  • Spec
  • Slides
  • Summary: Allow static initialization in a block format for static public/private fields.
  • Impact on SM: Mostly implemented,
  • Outcome: Conditional advancement to Stage 3 based on the following conditions: Issue #25: new.target should return undefined (aligns with methods/static fields), Issue #26: Support multiple interleaved static {} evaluated in document order alongside field initializers. Each block has its own var scope, as each block is essentially an immediately-invoked Method. Editorial review of above changes by DE and TC39 Editors

Ergonomic brand checks for private fields

  • Notes
  • Proposal Link
  • Issue Link
  • Summary: Support proper ergonomic brand checks for classes. This proposal aims at improving the integrity of code and ensuring you can trust that an object is what an object says it is. This was blocked from advancing in last meeting due to syntax overloading. It has been blocked again, roughly for reification, syntax overloading of the in operator (though no counter proposal) and process issues which did not have time to be discussed.
  • Impact on SM: Mostly implemented,
  • Outcome: Advanced to Stage 3.

Stage 3 Updates


Relative indexing method

  • Notes
  • Proposal Link
  • Slides
  • Summary: The at() proposal as discussed before, update regarding a new web compat issue.
  • Impact on SM: Requires implementation,

RegExp Match Indices

  • Notes
  • Proposal Link
  • Spec
  • Slidesk
  • Summary: Due to performance concerns, the proposal has been updated to use a flag d as an alternative approach.
  • Impact on SM: Requires implementation,

Proposals Seeking Advancement to Stage 2


Intl Locale Info

  • Notes
  • Proposal Link
  • stage 2
  • Summary: An API to expose information of locale, such as week data ( first day of a week, weekend start, weekend end), hour cycle, measurement system, commonly used calendar, etc.
  • Impact on SM: Will need implementation
  • Outcome: Advanced to Stage 2.

Intl DisplayNames v2

  • Notes
  • Proposal Link
  • stage 2
  • Summary: Adds further coverage to the existing Intl.DisplayNames API.
  • Impact on SM: Will need implementation
  • Outcome: Advanced to Stage 2.

Dynamic code brand checks

  • Notes
  • Proposal Link
  • Slides
  • Summary: Allow hosts to create code-like objects and change HostEnsureCanCompileStrings(callerRealm, calleeRealm) to HostValidateDynamicCode(callerRealm, calleeRealm, codeString, wasCodeLike). Hosts can change the to code string to be compiled.
  • Impact on SM: none
  • Outcome: Did not advance, requires a much more narrowly stated purpose that is within the conception of what works for the language across hosts.

JS Module Blocks

  • Notes
  • Proposal Link
  • Spec
  • Slides
  • Summary: Introduces “inline modules”. The lack of inline modules in JavaScript has spawned some best practices that are really just workarounds and more often than not have negative performance implications. Sometimes, the lack of inline modules even form a hindrance to the adoption of APIs.
  • Impact on SM: Will need implementation
  • Outcome: Advanced to Stage 2.

do expressions

  • Notes
  • Proposal Link
  • Slides
  • Spec
  • Summary: Write in an expression-oriented style, scoping variables as locally as possible:
    let x = do {
    let tmp = f();
    tmp * tmp + 1
    };
    
  • Impact on SM: None.
  • Outcome: Did not advance; No consensus on if return statements should be banned, and no consensus on if loops should be banned as last statements.

Stage 2 Updates


Temporal

  • Notes
  • Proposal Link
  • Slides
  • Summary: Introduces a new date/time library. They will be seeking stage stage 3 in March, and we have to make sure we are comfortable with it by then. The champion group has been collecting feedback, and our team did an inital review.
  • Impact on SM: Proposal is ready for review

ResizableArrayBuffer and GrowableSharedArrayBuffer

  • Notes
  • Proposal Link
  • Slides
  • Summary: Introduced two potential changes: One around OOB, which would allow an array that went out of bounds to go back within bounds. The other around allowing implementations to round up to the page size. This appears problematic from our perspective, as it would expose the page size of the OS.
  • Impact on SM:

Realms

  • Notes
  • Proposal Link
  • Summary: Realms exposes a new global without a document for use by JS programmers, think iframes without the document. Google presented a potential alternative to the proposal currently being discussed. No slides yet, awaiting further details. See #24 and #23 for further details.
  • Impact on SM:

Proposals Seeking Advancement to Stage 1


Array find from last

  • Notes
  • Proposal Link
  • Slides
  • Summary: Proposal for .findLast() and .findLastIndex() methods on array.
  • Outcome: Advanced to stage 1

Extend TimeZoneName Option Proposal

  • Notes
  • Proposal Link
  • Slides
  • Summary: Extend the timeZoneName option in Intl.DateTimeFormat object to support more formatted options.
  • Outcome: Advanced to stage 1

eraDisplay option for Intl.DateTimeFormat

  • Notes
  • Proposal Link
  • Slides
  • Summary: Allow displaying era information, for non-gregorian calendars such as the Japanese calendar, which recently underwent an era change.
  • Outcome: Advanced to stage 1

Adopting Unicode behavior for set notation in regular expressions

  • Notes
  • Proposal Link
  • Slides
  • Summary: Add syntax & semantics for the following set operations: difference/subtraction (in A but not in B), intersection (in both A and B), nested character classes (needed to enable the above)
  • Outcome: Advanced to stage 1

Intl LocaleMatcher

  • Notes
  • Proposal Link
  • Summary: i18n-supported websites often get a list of preferred locales via Accept-Language header or navigator.languages. They then try to determine the best available locale based on the set of locales that they support (and have translations for). This operation currently exists within ECMA-402 but is only available as an abstract operation. Surfacing this functionality as a top level API would improve locale negotiation correctness and developer productivity as sites will be able to reliably handle not only matching, but also aliases, fallbacks and such.
  • Outcome: Advanced to stage 1

async do expressions

  • Notes
  • Proposal Link for stage 1
  • Slides
  • Spec
  • Summary: Much like do expressions described above: Write in an expression-oriented style, scoping variables as locally as possible, but this time with async:
    async do {
    await readFile('in.txt');
    let query = await ask('???');
    // etc
    }
    
  • Outcome: Advanced to stage 1

index from end syntax

  • Notes
  • Proposal Link
  • Slides
  • Summary: introduces a new symbol like ^ that allows indexing from the end in array like objects. For example myArray[^1] would give the last element. Would enable slice notation, such as myArray[1:^1].
  • Outcome: Advanced to stage 1

class brand check

  • Notes
  • Proposal Link
  • Slides
  • Summary: Introduces a “class brand check” to check if a member is an instance of the class. Non-spoofable, and would fix instanceof
  • Outcome: Advanced to stage 1

defer module import eval

  • Notes
  • Proposal Link
  • Slides
  • Summary: Introduces a way to lazily instantiate modules, synchronously. This is a revisit of the original proposal for dynamic import, and seeks to address some of the issues we have in firefox around lazy loading.
  • Outcome: Advanced to stage 1