Re: Object.mixin() reacher proposal

2013-04-14 Thread Andrea Giammarchi
apologies getOwnPropertyDescriptor( source, key ) should have been getOwnPropertyDescriptor( enricher, key ) On Sun, Apr 14, 2013 at 1:58 AM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: what I've written here:

Re: Object.mixin() reacher proposal

2013-04-14 Thread Andrea Giammarchi
also, in case you are guessing the typo .. reacher because it could reach more (older) engines, doing a joke with richer got it? .. too damn fun, I know! On Sun, Apr 14, 2013 at 2:04 AM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: apologies getOwnPropertyDescriptor(

Re: Object.mixin() reacher proposal

2013-04-14 Thread Andrea Giammarchi
OK, maybe just code was a non-sense ... So, the idea behind is mark a function explicitly as mixin ... how ? Any function that is passed and has an empty prototype (then is user defined or native) could be considered invocable as mixin. function addFunctionality() { this.method = function ()

Re: Object.mixin() reacher proposal

2013-04-14 Thread Andrea Giammarchi
right, I've simplified a lot and tested cross platform: https://github.com/WebReflection/object-mixin#object-mixin thoughts? On Sun, Apr 14, 2013 at 10:07 AM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: OK, maybe just code was a non-sense ... So, the idea behind is mark a

Re: Object.mixin() reacher proposal

2013-04-14 Thread Angus Croll
Lending my support to Object.mixin accepting a function as the argument—but no surprise there I guess :) Note: since functional mixins and constructors are syntactically identical we can now get gorgeously expressive—and make type inheritance way simpler (for the first time allowing multiple type

Re: Object.mixin() reacher proposal

2013-04-14 Thread Andrea Giammarchi
My previous version was doing that in a probably too smart way so I've simplified the proposal simply accepting, in that example Object.mixin(Thung.prototype, Thing.proottype); Object.mixin(Thung.prototype, Thang.proottype); It does not look so black magic anymore but it's way less ambiguous

Re: Object.mixin() reacher proposal

2013-04-14 Thread Angus Croll
yeah that's better - I was having a senior moment - most constructor functions will normally reside in the prototype of course On Sun, Apr 14, 2013 at 1:59 PM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: My previous version was doing that in a probably too smart way so I've

Re: Object.mixin() reacher proposal

2013-04-14 Thread Andrea Giammarchi
somebody already raised the concern what if I want to mixin the function as object, not as callable I think being [[Call]] not possible to mixin as object functionality, and being functions all by default having ownProperties such [arguments, name, length, caller] .. that would simply clash so

Re: Object.mixin() reacher proposal

2013-04-14 Thread Peter Seliger
Hi, maybe one should discuss terminology first. What has been rediscovered within the last decade every now and again by JavaScript programming individuals, this languages capability for functional or function based mixins, might deserve a closer look, before running into what I would call a meta

Re: Object.mixin() reacher proposal

2013-04-14 Thread Andrea Giammarchi
not sure changing name is a thing to promote, it makes method name clashing easier but it can be achieved simply attaching properties to a specific object and then pass that as mixin ... Object.mixin(target, { on: source.addEventListener, off: source.removeEventListener, has:

Re: Object.mixin() reacher proposal

2013-04-14 Thread Andrea Giammarchi
updated API with Trait and the extra argument: https://github.com/WebReflection/object-mixin#api how does the code look like now: https://github.com/WebReflection/object-mixin/blob/master/src/object-mixin.js is your browser passing all tests? (if green, yes)