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

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 >

Re: MAIN subroutine

2018-07-19 Thread Brad Gilbert
run after MAIN, which doesn't make a lot of sense. (As in it wouldn't make sense to even have a mainline.) There is no way to mix the mainline and running MAIN without making it special case. One goal of the design of Perl 6 is to reduce special cases. Running a something like a MAIN subroutine at

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