Bound instance-function vending (was RE: Arrow binding)
Tab Atkins Jr.
jackalmage at gmail.com
Sat Apr 28 19:23:28 PDT 2012
On Sat, Apr 28, 2012 at 11:13 AM, Angus Croll <anguscroll at gmail.com> wrote:
> 1) Kevin et al suggested YAGN call/apply on (non-method) functions. Here's a
> pretty neat example where call/apply is a perfect fit for standalone
> functions - and would break if replaced with fat arrows.
> It's a simplified version of a a localStorage function (itself a mixin BTW)
> which defines standard encoding methods and then mixes in whatever storage
> technique is available to the browser. (An added bonus of having functions
> here, aside from privacy, is that we can employ hoisting to move the
> implementation nitty-gritty to the bottom, so as not to obscure the core
This is a mixin, which means that it needs methods, not functions.
Fat arrows aren't meant for methods.
This should rightly use 'function' (which is meant for methods), or
eventually use a mixin syntax. (We should keep this in mind as an
example of mixins, so we don't accidentally forbid the ability to
choose which mixin to use dynamically, like this does.)
More information about the es-discuss