Am Mittwoch, 1. November 2006 07:43 schrieb Allison Randal:
> We
> may add compile-time construction of classes at some point as an
> optimization, but we'll never eliminate runtime construction.
Of course not. I never said that.
> > To get around that the following came to my mind:
> >
> > - we create a class when needed during compile time
> I can see the appeal, but unfortunately it won't give us all the
> features we need. This is certainly an option to consider if/when we do
> add compile-time construction of classes, with the understanding that
> only a subset of cases would be able to use it (as is true of most
> optimizations).
It's actually not an optimization IMHO. It could be one, if we add support for
adding attributes at compile-time too [1]. But for now, I'm just speaking of
consolidating class construction code.
We now have:
compile-time run-time
-----------------------------------------------
.namespace ['Foo']
.sub bar :method
.sub baz :method :vtable(..)
cl = newclass 'Foo'
addattribute cl, 'x'
addmethod cl, 'blurb', meth
The namespace directive in combination with :method is defining parts of a
class namely all the statically compiled methods and the namespace. The
problem is how to forward the compile-time part of a class properly to the
run-time.
Actually the current implementation is partly wrong to deal with too much
usage of:
.namespace ['Foo']
.sub _init :load
cl = newclass ['Foo'] # would be ['Foo';'Foo']
and similar. Above should be
.sub _init :load
cl = newclass ['Foo'] # ['Foo']
...
.namespace ['Foo']
Having a class available at compile-time would elminate this ambuigity.
> Allison
leo
[1] in fact, we can do that already - see my answer to Nicholas.