On Mon, Feb 18, 2013 at 06:47:52PM +0100, Gerhard R. wrote:
> > 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.

At the moment NQP/Rakudo do not emit :main subs, but they once did, and
if we ever attempt to do pre-compiled standalone .pbc/.exe files
instead of always invoking Perl 6 source code, then NQP/Rakudo will 
again be generating subs with :main.  

Such :main subs are *not* the mainline of the code being compiled, 
they are auxiliary to simply load the rest of the Perl 6 compiler 
and libraries prior to invoking the compiled mainline.  Subs marked
:main must not be executed when run from an already-loaded compiler 
instance, nor are they the ones that need their outer context set.

The HLL mainline (first) sub has to be reliably located so that 
its outer context can be properly set when run from something like
eval().  It also has to appear ahead of any other lexically nested 
subs (Parrot requires this in order for :outer to work).

> However, both solutions depend on imcc implementation details, which
> is probably not a good idea. 

Somewhat false.  The meanings of :main, :load, and :init have been 
documented for quite some time (PDD 19), they aren't merely 
"imcc implementation details".

> 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.

Okay, as long as it's custom tag*s* to mark the sub*s* we want.
We need to be able to locate both the "Perl 6 mainline sub" and a
"Parrot sub to be automatically invoked when run via Parrot command line", 
and they are generally not the same sub.  The current pull requests 
to NQP and Rakudo definitely confuse the two, thus I'm rejecting them
as they stand now.

Pm
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev

Reply via email to