What about existing code that might use `void` in a way that's confused
with your static type proposal? Suddenly it would start behaving
differently.

On Sun, Jun 3, 2018 at 8:32 PM, YU HengChun <achun....@qq.com> wrote:

> > A separate question is, how would String cover strings across realms,
> considering that 'abc' instanceof String already returns false even in the
> same realm?
>
> There is no such way in the proposal.
>
> 提案中没有这样的写法.
>
> The real purpose of the expression in void is not the operation.
> It is description for typing, the literal semantics.
> It is compatible with the old engine. Even if it is operated, it will not
> have side effects.
>
> The new engine will extract the type description, and will not operate on
> it.
>
> void 中的表达式不是用来计算的, 是为了描述类型, 只是为了兼容陈旧的引擎, 在陈旧的引擎中它也是合法的, 老引擎里面它会被计算,
> 但不会有副作用.
>
> 新引擎会提取其中的类型描述, 不会去运算它.
>
>
> So, The correct way is:
>
> ```js
> function CustomString(x = void( Object instanceof String) || 'abc' ) {
>   // ...
> }
> ```
>
> The form `Object instanceof TYPE` is for backward compatibility.
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to