Search code examples
javascriptmultiple-inheritanceprototype-programming

Are there languages which support concatenative inheritance from multiple prototypes?


So that both prototypes and their descendants live their own independent lives by default.

I mean freely taking on new properties while forgetting where they come from (like with human memory -- often we know something without remembering where that knowledge comes from). Trying to find a natural form of conceptual model that works similar to our own development. If I am not mistaken, JavaScript, for example, would always trace where new properties come from.


Solution

  • The concatenative inheritance you are talking about is defined by not remembering the prototype, but just copying over the properties. This means no prototype chain, and no dynamic dispatch.

    JavaScript supports this trivially (e.g. using Object.assign or spread syntax in an object literal, with multiple sources), as do some other languages.