develooper Front page | perl.perl6.users | Postings from September 2022

Re: BEGIN {} question

Thread Previous | Thread Next
From:
Elizabeth Mattijsen
Date:
September 2, 2022 21:47
Subject:
Re: BEGIN {} question
Message ID:
588F11E8-9398-4B5B-93BB-A208B03F7A72@dijkmat.nl
> On 2 Sep 2022, at 22:52, ToddAndMargo via perl6-users <perl6-users@perl.org> wrote:
> 
> On 9/2/22 00:13, ToddAndMargo via perl6-users wrote:
>> Found something interesting
>> $ raku -c GetUpdates.pl6
>> Syntax OK
>> Will execute the BEGIN {}, not just
>> syntax check it.
> 
> The guys on the chat line said this is normal
> as `BEGIN` runs a compile time

How short *is* your memory?

> From: Elizabeth Mattijsen <liz@dijkmat.nl>
> Subject: Re: BEGIN {} question
> Date: 29 August 2022 at 09:44:30 CEST
> To: ToddAndMargo via perl6-users <perl6-users@perl.org>
> 
>> Question, would BEGIN go at the top or the bottom
>> of my code?  Seems the compiler would hit it first
>> at the top, but I do not know if it makes a full
>> pass of everything before firing off the BEGIN.
> 
> BEGIN runs at *compile* time.
> 
> This means that anything before the BEGIN statement in the code, is compiled and known and can be referenced in the BEGIN block.
> 
> Anything *after* the BEGIN statement is still unknown to the compiler and can therefore *not* be referenced.
> 
> 
> Liz


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About