Ok, so I got to thinking about Parrot and compilation last night. Then
something occurred to me, and I'm not sure how it works.

When Perl sees:

        class Joe { my $.a; method b {...} }
        my Joe $j;

Many things happen and some of them will require knowing what the result
of the previous thing is.

More to the point, Perl 6's compiler will have to parse "class Joe",
create a new object of type Class, parse and execute the following
block/closure in class MetaClass, assign the result into the new Class
object named Joe and then continue parsing, needing access to the values
that were just created in order to further parse the declaration of $j

There are several ways this can be accomplished:

     1. Have a feedback loop between Parrot and Perl 6 that allows the
        compiler to execute a chunk of bytecode, get the result as a PMC
        and store it for future use. This will probably be needed
        regardless of which option is chosen, but may not be ideal.
     2. Have a pseudo Perl 6 interpreter in the compiler which can
        execute a limited subset of Perl 6 that is allowed inside of
        class and module definitions (Larry implied that they were not
        limited in this way, but if they were, compilation could be
        optimized a bit).
     3. Attempt to build a one-shot, bytecode stream that outputs a
        bytecode stream that represents the program. This would be the
        fastest in the general case, and would make pre-bytecoded
        libraries much easier to implement. However, it would also mean
        that class and module definitions could not affect the grammar
        of the language, and Larry has said that won't be the case :-(

To me, #2 looks most attractive, but requires some duplication of
effort.

How easy would it be to interact with Parrot in the way that #1
proposes?

-- 
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback


Reply via email to