Overriding Map/etc with get/set hooks?

Tab Atkins Jr. jackalmage at gmail.com
Mon Aug 11 18:44:17 PDT 2014


On Mon, Aug 11, 2014 at 6:33 PM, Domenic Denicola
<domenic at domenicdenicola.com> wrote:
> When I last looked at this, it seemed like a perfect use case for [Traits](http://soft.vub.ac.be/~tvcutsem/traitsjs/tutorial.html). A "Set-like" trait would require definitions for add, delete, and [Symbol.iterator], but provide has, forEach, entries, keys, values, clear, and size, plus any future interfaces.
>
> Then you would implement such set-likes by mixing in the set-like trait into your prototype, which contains type-restricted definitions for add, delete, and [Symbol.iterator] (plus probably some of the other methods for performance reasons).
>
> Presumably a future version of ES that contains traits would define set-like, map-like, and other traits that could be used.

Yes, something Trait-like would be sufficient.

~TJ


More information about the es-discuss mailing list