On Fri, Sep 6, 2019 at 8:04 AM Andrea Giammarchi
<andrea.giammar...@gmail.com> wrote:
> Indeed I'm not super convinced myself about the "branching issue" 'cause 
> `const result = this?.is?.branching?.already` and all I am proposing is to 
> hint the syntax where to stop in case something else fails down the line, as 
> in `const result = this.?.is<?.branching?.too` to know that if any other part 
> is not reached, there is a certain point to keep going (which is, example, 
> checking that `result !== this`)

Important distinction there is that ?. only "branches" between the
intended type and undefined, not between two arbitrary types. The
cognitive load between those two is significantly different.

In particular, you can't *do* anything with undefined, so
`foo?.bar.baz` has pretty unambiguous semantics - you don't think you
might be accessing the .baz property of undefined, because that
clearly doesn't exist.

That's not the case with mouse, where it's not clear, at least to me,
whether `foo<?.bar.baz` is doing `(foo.bar ? foo.bar : foo).baz` or
`foo.bar.baz ? foo.bar.baz : foo` or even `foo.bar ? foo.bar.baz :
foo`. All three seem at least somewhat reasonable, and definitely
*believable* as an interpretation!

~TJ
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to