Proposal to add symbol: "hasInstanceStrict"

Mike Samuel mikesamuel at
Tue Feb 20 18:05:05 UTC 2018

On Tue, Feb 20, 2018 at 12:33 PM, Александр Ефремов <mr.efrem at>

> Anyone else has interes to this proposal?

I'm probably just going to echo themes that T.J. has dealt with better, but:

Things i like:
- provides preconditions
- guards locals

Things I don't like:
- doesn't deal with postconditions
- somewhat redundant with annotations
- adds syntax

It seems that there are two separable issues:
1. Defining guards
2. Syntax for specifying guards.

It seems to me that (2) might be doable with annotations for locals,
so deploying guards could build on annotations.

Where your proposal shines, is in a definition of a guard.
I don't much like the way the definition is tied to classes though.
Maybe, for
  class C {}
  C(x)  // [[Call]] not [[Construct]]
default to (x instanceof this) unless the static property you propose is

That would allow you to use any function type as a value predicate which is
minimum needed for a guard.

Leave sub-types that don't override [hasInstance] from super-types to

If confusion between (new C(x)) and (C(x)) is too much of a hazard, maybe
adjust the calling convention for guards so that they always receive a
symbol as the first argument, so can switch between acting as a predicate
telling developers how to create class instances.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list