Re: MAIN subroutine

2018-07-20 Thread JJ Merelo
In general, it needs to be improved. https://github.com/perl6/doc/issues/2167 Please add to that issue or open another one to comment this specific fact. Cheers JJ

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