Skip to content

Comment on Fargo: new Scheme-like language working in Node.js/browserparent

Comments

I notice that it doesn't support multiple inheritance or multimethods; out of curiosity, is that because of a principled objection to them, or more because it wouldn't be convenient to implement them?

At the beginning I tried implementing various object systems. The first one was indeed multiple inheritance with multimethods, based on C3 linearization (http://en.wikipedia.org/wiki/C3_linearization) and didn't use the prototype chain, but wasn't finished. The second one was similar to Clojure's protocols (define-protocol, extend-protocol, ...), but wasn't very handy.

The current one is single-inheritance, because it uses the prototype chain. It's a compromise between speed and usefulness. I'd prefer having multimethods (and maybe also multiple inheritance), but speed is a bit more important, as JavaScript is already quite slow.

So far I'm quite pleased with the single-inheritance and single dispatch solution, which basically works like that: https://gist.github.com/866506

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.