Hey Dean, I also really love clojure protocols and in fact tried to propose few extensions for private names to make them little more usable as such:
https://mail.mozilla.org/pipermail/es-discuss/2012-June/023657.html https://gist.github.com/2967124 Unfortunately thread did not got any replies from anyone. That being said I did couple of experiments in these area: Implemented clojure like protocols as library: http://jeditoolkit.com/2012/03/21/protocol-based-polymorphism.html#post But after using it for some time I realised it was not very javascripty, so I have prototyped a more minimalistic version, which I'm using happily since then: https://github.com/Gozala/method I still really wish we could make private names callable such that: var method = Name() method(object, arg1, arg2) => object[method](arg1, arg2) Regards -- Irakli Gozalishvili Web: http://www.jeditoolkit.com/ On Thursday, 2012-09-13 at 14:46 , Dean Landolt wrote: > The real point I'm trying to make is that Name objects give us something akin > to clojure's protocols. Imagine an "orm" protocol -- this is just a set of > names that must exist on an object (or its proto chain). An object can > implement any number of protocols (or interfaces, or whatever) without fear > of conflict. You can easily override any implementation so long as you have a > handle on the appropriate name object. This is easier, better looking and > more correct than anything we can do today. It's not too disimilar from using > using instanceof as a brand, but without the pitfalls (it doesn't fall flat > crossing sandbox boundaries). This is a safe and flexible inheritance model > that works just as a js programmer would expect, all without begging for > mutable or multiple prototypes.
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss