spacer spacer spacer


Circles and Arrows

Henry asked me the other day if I could draw a picture of how my Classy Javascript works. Here’s what I came up with:

If you look at the MySubclass instance, it shows how its myattr slot is inherited up the implicit prototype chain. The Cyan things are meant to be Class objects, the Pink things are Class Prototypes, and the Orange things are Objects.

Classes Diagram

Class is not a constructor (so not a Function), it is a factory (so an Object). Instance, and the things that Class makes are constructors (so Functions). When Class makes a class, it has to copy properties into the new class and prototype (since it is not a constructor, so can’t use inheritance). I have tried to illustrate how Class copies make and addProperty to the new class and the initial property values to the new prototype. I omitted the properties that are inherited from Instance (grey-ed) from the class instances, just for simplicity, but they are there and accessible through the implicit prototype chain. All objects that obey our Class protocol will be instances of Instance, as you can see by tracing the implicit prototype chain.


As lovely a piece of prose as I’ve read for a quite. (Call me perverse, but this is the sort of work that keeps my nose to the tech_docs grindstone!)

2006-06-06 13:29 | Ben Tremblay

Post a comment

Thanks for signing in, . Now you can comment. (sign out)

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Remember me?

You are not signed in. You need to be registered to comment on this site. Sign in