Extensible destructuring proposal
samuel.hapak at vacuumapps.com
Tue Jul 21 15:18:53 UTC 2015
> On 21.7.2015, at 16:23, Bergi <a.d.bergi at web.de> wrote:
> Aw, when I read "extensible destructuring" I had hoped to see an extension to the destructuring syntax, not to see how semantics of destructuring objects are changed.
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, so your solution is a lot more flexible than mine. Actually, mine proposal is just special case of yours. I could implement `E[@@extractor]` that just tries to find `__get__` method on object being extracted and uses it.
The only downside I see is the verbosity.
Could you please elaborate more on the use cases for this? I am not used to Scala so my imagination is currently very limited:) I know that I would really really need different destructuring for different object types (otherwise it is insanely verbose to use Immutable Maps), but I can’t think of use case for having multiple different destructurings for single type.
Could you show some examples? Thanks!
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3589 bytes
Desc: not available
More information about the es-discuss