Hi,
You can have as many mix-ins as you like, which is why the number of
arguments is variable:
"...any arguments passed are treated as objects, and their methods are
copied over ("mixed in") as instance methods of the new class. In
cases of method name overlap, later arguments take precedence over
earlier arguments."[1]
> Creating and instantiating a prototype class is notoriously slow.
I hadn't realized that using `arguments` (as opposed to
`arguments.callee`) was slow, but a quick experiment shows that you do
indeed pay a performance penalty for it on some major browsers (not
typically as bad as for `arguments.callee`, but pretty bad). Very
interesting, thanks for that. That would indeed hit both Class.create
and initialization, since initialization requires that the Prototype-
generated constructor hands `arguments` to the initializer.
I think the larger issue, though, with defining (creating) classes is
because of Prototype's support for supercalls, which requires that it
decompile every single function in the class (and all mixins) and
perform regexes on each of the resulting strings -- which is not just
a speed issue, but a standards issue as well. I've proposed a solution
for it[2].
The same applies to instantiating: if you use a supercall in your
initializer (which is quite common), you'll pay a big speed penalty
for that -- each method call involving a supercall is very slow
indeed, Prototype actually creates a new function on the fly for the
call, every time(!). My proposal fixes that as well.
[1]
http://api.prototypejs.org/language/class.html#create-class_method
[2]
http://groups.google.com/group/prototype-core/browse_thread/thread/db9ccdaae4f7f705#
Happy coding,
-- T.J.