Extensible destructuring proposal

Bergi a.d.bergi at web.de
Tue Jul 21 16:19:20 UTC 2015


Samuel Hapák schrieb:

> I find your idea really interesting. If get it, benefit of your approach is that user explicitly specifies how to extract data instead of relying on extraction method defined by object being extracted.
> This way, you can create multiple competing extractors

That wasn't my primary goal (indeed most data structures would have only 
a single extractor).
The main benefits I see are:
* explicit is better than implicit
* works anywhere in a destructuring pattern, not only the topmost level
* can be chosen not to be used (e.g. for `let {size} = myMap;`)

> The only downside I see is the verbosity.

That's an advantage imo :-)

> Could you show some examples? Thanks!

I don't think there's much more than the ones I already gave.
Notice that those `NoOptions` and `WithOptions()` was even an example 
for multiple extractors to be used for "destructuring" factory functions 
(by applying them), though I don't know whether that's the best solution 
for this `import` problem.

  Bergi



More information about the es-discuss mailing list