(To make the summarizer's life easier, here is a repost of
http://pugs.blogs.com/pugs/pil/ in the past week; I'll also post
another one on Pugs-Rule developments.)Roles support in PIL.Native runtime.Almost two months ago when I was in .nl, Stevan and I worked out the ObjectSpace bootstrapping plan, decomposing Perl 6's object model into method calls of a few native types, so we can build all boxed types, classes, roles and containers on top of them. This approach is needed because our target runtimes (Perl5, Parrot, _javascript_) have wildly different method dispatch semantics. In the PIL1 era, each backend needs to bootstrap the object model differently, resulting in massive code duplication and subtly different semantics on eg. private methods and role composition. Today I'm glad to report that Stevan's Bootstrap code is capable of representing roles, private methods, multiple inheritance with C3 dispatch order, built on full introspection and object space enumeration capabilities offered by the PIL.Native (PILN) runtime. PILN is a small language with only literals, variable lookups and primitive (potentially statically bound) method calls. Typing make pil in the Pugs source tree will build its interpreter; tests are in the t/pil/ directory. The next step is to represent container types as instances of ::Class,
and group their methods into a Roles hierarchy. Fortunately, Scala,
Ruby and C# has done much of the hard work for us -- with Code,
SigList, ArgList and other PIL2 base classes implemented, we
can then hook it to a Perl 6 parser and complete the 6.28.0 milestone. Scalar container lands.Scalar container support has landed to PILN runtime. To wit:
Moreover, ::Int now represents a true BigInt (internally
using the Haskell type Integer),
which differs from its unboxed representation with limited precision.
This is correct according to the spec, and unlike the old runtime which
uses BigInts everywhere. Unicode-aware ::Str types will get
the same treatment soon. ::Array and ::Hash lands.Today Leo sent me a set of design notes, including his recent thinking about how Parrot's PMC layout and interfaces may be improved, allegedly inspired by pugs/docs/quickref/data. Coincidentally, I was feeling unhappy about the steadily-growing vtable of PILN's NativeObj structure, so I implemented Leo's design, and it worked beautifully. The basic idea is that instead of having a large fixed set of things that all objects may do, we split them out into interfaces, which are simple mappings from method names to native code. At class composition time, the class selects a representation for its object by mixing in one or more interfaces. The chosen interfaces determines which primitive operations the object can perform, which stays immutable during the entire runtime (just like the old vtables did), and as such may still be checked statically. Under this scheme, we don't need to allocate stub throw-an-execption for value classes's set method, and the distinction of Containers is clear: unlike ordinary Objects, they do not use the p6opaque representation (set_attr, get_attr...). I have just coded in p6array and p6hash representations, with primitive operations such as fetch_elem and store_elem. This also addressed the problem of how attributes are handled when we extend builtin classes with Perl 6 code. Because "has $!x = 3" ultimately desugars into set_attr operations, which does not exist in a boxed p6integer, code like "class ::Int is extended { has $!foo }" can be rejected at compile time, which is probably a good thing. Tomorrow I'll move to ::Args and ::Sigs, and ::Code after them if all works out. Then we'll add some sugar to it and serve the dish by compiling PIL2 to it. It's already smelling good... |
signature.asc
Description: OpenPGP digital signature