Re: Closures, compile time, pad protos

2006-11-26 Thread Anatoly Vorobey
On Thu, Nov 23, 2006 at 05:09:17PM -0500, Buddha Buck wrote: > The way I see it, everything which defines a separate lexical scope (a > block, a function, a closure. I forget if in "my $a; ... ; my $b" $b > is visible in the ellipsis. If not, then a "my" statement also > defines a separate lexica

Re: Closures, compile time, pad protos

2006-11-24 Thread Buddha Buck
On 11/22/06, Anatoly Vorobey <[EMAIL PROTECTED]> wrote: First of all, thanks a lot for your comments. On Wed, Nov 22, 2006 at 06:43:12PM -0500, Buddha Buck wrote: > >{ > > my $x = something(); > > if $x==1 { > >...code... > > } > >} > > > My experience with other statically typed by extre

Re: Closures, compile time, pad protos

2006-11-22 Thread Anatoly Vorobey
First of all, thanks a lot for your comments. On Wed, Nov 22, 2006 at 06:43:12PM -0500, Buddha Buck wrote: > >{ > > my $x = something(); > > if $x==1 { > >...code... > > } > >} > > > My experience with other statically typed by extremely flexable > languages is that the pads tend to be arra

Re: Closures, compile time, pad protos

2006-11-22 Thread Buddha Buck
Keep in mind that I am only an egg, and I am putting my intuition and experience with similar languages to mind. Perl6 might be doing things differently than I expect. On 11/22/06, Anatoly Vorobey <[EMAIL PROTECTED]> wrote: To add some more confusion to what Yuval wrote: In general, it doesn't

Re: Closures, compile time, pad protos

2006-11-22 Thread Anatoly Vorobey
To add some more confusion to what Yuval wrote: In general, it doesn't seem to be very clear how inner (lexically) subs see their enclosing lexical environments. Possibly I'm simply very confused, in which case un-confusing me would be much appreciated. Here're some code snippets. { my $x =

Re: Closures, compile time, pad protos

2006-11-22 Thread Yuval Kogman
On Wed, Nov 22, 2006 at 18:55:15 +0100, Juerd wrote: > Yuval Kogman skribis 2006-11-22 16:01 (+0200): > > my $x ::= 3; > > sub foo { say ++$x }; > > Why would you be allowed to ++ this $x? It's bound to an rvalue! Perhaps my $x ::= BEGIN { Scalar.new( :value(3) ) } What w

Re: Closures, compile time, pad protos

2006-11-22 Thread Juerd
Yuval Kogman skribis 2006-11-22 16:01 (+0200): > my $x ::= 3; > sub foo { say ++$x }; Why would you be allowed to ++ this $x? It's bound to an rvalue! -- korajn salutojn, juerd waalboer: perl hacker <[EMAIL PROTECTED]> convolution: ict

Re: Closures, compile time, pad protos

2006-11-22 Thread Yuval Kogman
And what about: foo(); for 1..3 { my $x ::= 3; sub foo { say ++$x }; say ++$x }; BEGIN { foo(); foo(); } or worse: sub moose { my $x = 3;

Closures, compile time, pad protos

2006-11-22 Thread Yuval Kogman
Hi, Anatoly and I don't know what this bit of code prints: foo(); foo(); for 1..3 { my $x ::= 3; sub foo { say ++$x }; say ++$x }; Is it 4, 5, 6, 6, 6 or 4, 5, 3, 3, 3? It's almost definitely not 4, 5, 6, 7, 8. I c