Skip to content

Instantly share code, notes, and snippets.

@angus-c
Created October 17, 2012 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angus-c/3904946 to your computer and use it in GitHub Desktop.
Save angus-c/3904946 to your computer and use it in GitHub Desktop.

Purists would say NO because 1) a module resembles a class not an instance - it has module props and instance props and need not be instantiated 2) when used as a mixin it actually extends the class not the instance 3) when module methods are accessed directly this is pure composition.

But in spirit YES (when used as mixins) because the relationship is a "like-a" not "is-a", and from a developer perspective, module instance methods are accessed by internal delegation. The convention is prototypes are referenced by cloning or internal delegation - the former relationship is static, the latter dynamic, as you point out in your question.

I think the definition of a prototype is not fully flushed out. We'd do better to identify them by intent rather than by their cold technical characteristics, as some attempt to do - there are just too many flavours and too many languages. To that end I feel mixins are quite prototypal in spirit - much more so that JS constructor-prototype chains because they exploit alikeness rather than categorize into types - and that's the nub of the prototypal solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment