Extensible destructuring proposal
Bergi
a.d.bergi at web.de
Tue Jul 21 16:45:26 UTC 2015
Ben Newman schrieb:
> That said, virtually every time I've written an unapply or unapplySeq
> method in Scala, it has been with multi-case pattern matching in mind, and
> we're only talking about destructuring assignment here, which I suppose is
> like a single-case pattern match.
Right, we don't really have pattern matching in ES yet. I don't want to
introduce that as well, it would be a pretty heavy change imo.
> If you have time/motivation to put together a proposal for
> Symbol.extractor, I would very much encourage you to think about the
> possibility of introducing multi-case pattern matching as well, as I think
> that would add significant value to the proposal, as well as highlighting
> some tricky issues.
I've seen that Scala returns an Option for a pattern. My first thought
was to make @@extractor return an empty iterator, but I'm not sure
whether that's semantically sound.
We then could consider an iterator to be "not matching" if any of the
target elements are left `undefined`, i.e. when the iterator is
exhausted before all elements have gotten a value, similar to default
initialisers are handled today.
Do you think that is viable?
Bergi
More information about the es-discuss
mailing list