Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

placeholder vs. lexical variables

3 views
Skip to first unread message

Dan Kogai

unread,
Apr 11, 2006, 1:17:10 PM4/11/06
to perl6-l...@perl.org
Folks,

I found this when I was playing w/ pugs.

pugs> { $^x }.(42)
42
pugs> { my $z; $^x }.(42)
*** Undeclared variable: "$^x"
at <interactive> line 1, column 10-14

So far as I see s06, there's nothing wrong w/ the statement above. I
just want to make sure this is not a perl6 feature.

I found this when I tried

{ my %n; { %n{ $^n } ||= ($^n <= 2 ?? 1 !! &?BLOCK($^n-1) + &?
BLOCK($^n-2)) }.($^n) }.(42)

This fails on pugs while

-> $n { my %n; { %n{ $^n } ||= ($^n <= 2 ?? 1 !! &?BLOCK($^n-1)
+ &?BLOCK($^n-2)) }.($n) }.(42)

beautifully returns 267914296.

Dan the Yet Another Pugs Addict

Audrey Tang

unread,
Apr 11, 2006, 8:57:00 PM4/11/06
to Dan Kogai, perl6-l...@perl.org
Dan Kogai wrote:
> I found this when I was playing w/ pugs.
>
> pugs> { $^x }.(42)
> 42
> pugs> { my $z; $^x }.(42)
> *** Undeclared variable: "$^x"
> at <interactive> line 1, column 10-14
>
> So far as I see s06, there's nothing wrong w/ the statement above. I
> just want to make sure this is not a perl6 feature.

This is a Pugs bug, so perl6-compiler is perhaps more adequate. :-)

Please commit a test for it somewhere (in
t/subroutines/implicit_parameters.t maybe?), as I've just fixed the bug.
(r9913)

{ my %n; { %n{ $^n } ||= ($^n <= 2 ?? 1 !! &?BLOCK($^n-1) +

&?BLOCK($^n-2)) }.($^n) }.(42)

now evaluates to 267914296 here too. :)

Audrey

signature.asc
0 new messages