Re: MAIN subroutine

2018-07-19 Thread Brandon Allbery
I should mention something less obvious as well: a declaration both manipulates symbols known to the compiler, and usually causes allocation of storage at runtime; and for classes, composition has runtime components. Among other things that must be split between compile-time and runtime. So it's no

Re: MAIN subroutine

2018-07-19 Thread Laurent Rosenfeld via perl6-users
Thanks Brandon for your answer. Yes, I agree that it makes sense that declarations (and initializations) outside any sub should run before the MAIN sub. And I agree that we should probably avoid combining a MAIN sub with non-declaring code. (And, as I said, I've never hit the case before because

Re: MAIN subroutine

2018-07-19 Thread Elizabeth Mattijsen
> On 19 Jul 2018, at 23:31, Laurent Rosenfeld via perl6-users > wrote: > I was expecting the MAIN message to be printed first. > > Did I miss something? Is my understanding wrong? I'd never seen that, but I > guess all my scripts using MAIN had all the code in subs called from MAIN. So > maybe

Re: MAIN subroutine

2018-07-19 Thread Brad Gilbert
The MAIN sub executes after the mainline. After all should MAIN be called before or after do-it('2') in the following? sub do-it(Str $string) { say $string; } do-it("1"); multi sub MAIN() { say "This is MAIN so this should print after the mainline"; } do-it

Re: MAIN subroutine

2018-07-19 Thread Brandon Allbery
Consider that "declarations" are actually executable code. They have compile-time meaning, but many also have runtime meaning. This is most obvious when it's a variable with an initializer: the initialization is at runtime, not compile time. Which means MAIN has to run after all such, or variables

MAIN subroutine

2018-07-19 Thread Laurent Rosenfeld via perl6-users
Hi folks, The documentation for the MAIN sub says that "the sub with the special name MAIN is executed after all relevant phasers." My understanding is that MAIN automatically executes before any code other than phasers happening at compile time or at the end or right after the end of compilation

[perl #133082] [LTA] precedence error !%foo:exists

2018-07-19 Thread Zoffix Znet via RT
Another user opened the same ticket on our primary tracker, so I'll close this one in favour of that one:https://github.com/rakudo/rakudo/issues/2098