On Fri Feb 13 20:46:31 2009, ch...@chrisdolan.net wrote:
> If you include statements in the body of a package, class, etc.  
> declaration, those are executed at :load time which happens  
> before :main.  So, globals like @*ARGS which are set up in ! 
> UNIT_START from :main are not yet established.  All three of the  
> following examples should have the same results, but the middle one  
> is wrong. Either setup of globals needs to happen before :load, or  
> the statements in the package, class, etc. need to be moved out  
> of :load methods.  I think the latter is better, since :load methods  
> are like BEGIN blocks.
> 
> ../../parrot perl6.pbc -e 'say "(", @*ARGS, ")";' f g h
> (fgh)
> 
> ../../parrot perl6.pbc -e 'package Foo { say "(", @*ARGS, ")"; }' f g h
> ()
> 
> ../../parrot perl6.pbc -e 'package Foo { sub run() { say "(", @*ARGS,  
> ")"; } }; Foo::run()' f g h
> (fgh)
> 

... Now a /different/ two of these work:

$ ./perl6 -e 'say "(", @*ARGS, ")";' f g h
(fgh)
$ ./perl6 -e 'package Foo { say "(", @*ARGS, ")"; }' f g h
(fgh)
$ ./perl6 -e 'package Foo { sub run() { say "(", @*ARGS,  ")"; } }; Foo::run()' 
f g h
Can not find sub Foo::run
  in main program body at line 1



-- 
Will "Coke" Coleda

Reply via email to