Some type system changes.

3 views
Skip to first unread message

Kris Kowal

unread,
Nov 20, 2008, 1:36:39 AM11/20/08
to Chiron
I've spent some time streamlining the type system. In particular,
about a month ago I discovered that calls to base.js#bind() were
dominating execution profiles in IE8 beta. In order to obviate the
need for binding, type constructors now implicitly receive "self" as
an argument, and this should be used instead of "this". It's the same
object as "this", but preferable since it can't be subverted with
method binding anyway. I also added the optional supr (super is a
reserved keyword) argument to the constructor, so you don't (and
can't) call getSuper any more. I've also added the option of using
the "exports" object instead of "this" or "module", since this will
likely better resemble modules in future ECMAScript.

Old and busted:

this.MyType = type([MyBase], function () {
this.init = function () {
this.getSuper(MyType).init();
};
});

New hawtness:

exports.MyType = type([MyBase], function (self, supr) {
self.init = function () {
supr.init();
};
});

My coworker, Darren, revealed a bug in the documentation system. The
docs that are generated tonight should be golden again. I'm going to
assume no-one noticed the hiccup, but sorry in any case. A while
back, I changed the comment scraper system to fix the boilerplate
script, which caused the doc scraper to break. They both work now.

With the calls to bind() removed from the type system, performance in
IE is comparable to FF thankfully. We can now use base.js in all
browsers without performance worries. That's a huge relief. base.js
contains all those nice little things you'd expect in a real language,
like the List, Dict, and Set types. Oh, also, a few days ago, I
factored the contents of base.js into separate files to make it easier
to edit. base.js publishes all of these submodules, so there's no
change to code using base.js, but you can take a look at each of the
files in base/* which are all down to a few hundred lines each instead
of one 5600 line file.

Kris

Reply all
Reply to author
Forward
0 new messages