Resurrection of whiteknight's eval_pmc branch

Gerhard R. gerd.r.devel at googlemail.com
Mon Feb 18 17:47:52 UTC 2013


> No.  The Eval PMC contains subs in the order in which they appear in
> the source, regardless of which sub is marked ":main".

To be pedantic: The Eval PMC contains the subs in the order in which
they appear in the constants table, and that happens to be the same
order in which they appear in the source because of the way imcc
works.

>> The PackfileView
>> PMC has a method .main_sub(), which does the same thing more
>> explicitly. At least, that's how I remember it. so it's the same Sub
>> being executed, we just get access to it in a different way.
>
> No, it's not the same sub (see above).  And in the case of NQP
> and Rakudo, we generally need access to the first sub in order
> to set its outer lexical context or other properties, not because
> it's the "main" sub or the one that is to be executed.

It *is* the same sub as long as there's no explicit :main as imcc
considers the first sub it encounters the main one until a sub
explicitly marked as such comes along.

The question is: Does NQP/Rakudo ever emit code with a :main sub not
in first position that gets passed to HLL::Compiler.compile()? If the
answer is 'no', then whiteknight's patch is equivalent.

However, both solutions depend on imcc implementation details, which
is probably not a good idea. A more proper solution would be to use a
custom tag to mark the sub we want to use explicitly (or an expixit
:main if conflicts are impossible) instead of relying on source
position.

-- gerdr


More information about the parrot-dev mailing list