Re: 'temp $x;' with no assignment
On Thu, Apr 06, 2006 at 05:36:56PM -0600, Luke Palmer wrote: : On 3/27/06, Larry Wall [EMAIL PROTECTED] wrote: : The p5-to-p6 translator will turn : : local $x; : : into : : temp undefine $x; : : Are you sure that that's not: : : undefine temp $x; : : It seems to me that the other way would undefine $x and then temporize it. Either way works. Remember I just said: (Well, plus the notion that, when applied to a mutator, the save/restore instruction is passed on to the mutatee to save itself before the mutation, not after.) And I'd say undefine is definitely a mutator even if you don't call it with .= syntax. All of these probably end up doing the same thing: (temp $x).undefine temp $x.undefine (temp $x).=undefine temp $x.=undefine temp($x .= undefine) temp($x = undef) temp $x = undef Larry
Re: 'temp $x;' with no assignment
On 3/27/06, Larry Wall [EMAIL PROTECTED] wrote: On Mon, Mar 27, 2006 at 02:54:05PM -0600, Jonathan Scott Duff wrote: : On Mon, Mar 27, 2006 at 10:46:02PM +0200, Yuval Kogman wrote: : On Mon, Mar 27, 2006 at 14:35:52 -0600, Jonathan Scott Duff wrote: : I think that if Ctemp is the new Clocal, then immediately after the : Ctemp $x line, $x should hold whatever flavor of undef is appropriate. : snip : Is there some reason we're huffmannizing : snip : : Because 90% of the code that people use local for in perl 5 is for : counting levels and automatically unwrapping them. The other 10% are : for more complex values. : : Make me believe your 90/10 numbers. Doesn't matter what the numbers are, it's the right thing to do. The default undef hack stems from the days when local() was trying to fill the role of my() as well. Nowadays temp() should just mean: Please arrange to restore yourself to your current value and nothing more. (Well, plus the notion that, when applied to a mutator, the save/restore instruction is passed on to the mutatee to save itself before the mutation, not after.) The p5-to-p6 translator will turn local $x; into temp undefine $x; Larry In order not do do some strange magic could you jsut do: temp($x)++; That seems clear and non magical to me. Just my 2 cents! ;) -- -- __ Eric Hodges
Re: 'temp $x;' with no assignment
On 3/27/06, Larry Wall [EMAIL PROTECTED] wrote: The p5-to-p6 translator will turn local $x; into temp undefine $x; Are you sure that that's not: undefine temp $x; It seems to me that the other way would undefine $x and then temporize it. Luke
'temp $x;' with no assignment
Hi, my $x = 5; { temp $x; # is $x 5 or undef? } # $x is definately 10 I think it should be 5 inside, because it makes it easy to write things like: my $x = 5; { temp $x++; # $x is 6 } # $x is 5 again and otherwise pretty much DWIMs, except from a historical perspective. -- Yuval Kogman [EMAIL PROTECTED] http://nothingmuch.woobling.org 0xEBD27418 pgpqVi7l1FtDo.pgp Description: PGP signature
Re: 'temp $x;' with no assignment
On Mon, Mar 27, 2006 at 05:26:48PM +0200, Yuval Kogman wrote: Hi, my $x = 5; { temp $x; # is $x 5 or undef? } # $x is definately 10 How did $x become 10?!?!? :-) I think it should be 5 inside, because it makes it easy to write things like: I think that if Ctemp is the new Clocal, then immediately after the Ctemp $x line, $x should hold whatever flavor of undef is appropriate. my $x = 5; { temp $x++; # $x is 6 } # $x is 5 again and otherwise pretty much DWIMs, except from a historical perspective. Is there some reason we're huffmannizing my $x = 5; { temp $x = $MY::x + 1;# or whatever the proper syntax is # $x is 6 } $x = 5; ?? Can you elaborate an example that would show this to be a boon? -Scott -- Jonathan Scott Duff [EMAIL PROTECTED]
Re: 'temp $x;' with no assignment
On Mon, Mar 27, 2006 at 14:35:52 -0600, Jonathan Scott Duff wrote: On Mon, Mar 27, 2006 at 05:26:48PM +0200, Yuval Kogman wrote: How did $x become 10?!?!? :-) GHC has this lovely error: my brain just exploded I think Perl 6 should have a similar runtime warning about how it's usiong my short term memory for storage ;-) I think that if Ctemp is the new Clocal, then immediately after the Ctemp $x line, $x should hold whatever flavor of undef is appropriate. snip Is there some reason we're huffmannizing snip Because 90% of the code that people use local for in perl 5 is for counting levels and automatically unwrapping them. The other 10% are for more complex values. -- Yuval Kogman [EMAIL PROTECTED] http://nothingmuch.woobling.org 0xEBD27418 pgpuO2LOJefPG.pgp Description: PGP signature
Re: 'temp $x;' with no assignment
On Mon, Mar 27, 2006 at 10:46:02PM +0200, Yuval Kogman wrote: On Mon, Mar 27, 2006 at 14:35:52 -0600, Jonathan Scott Duff wrote: I think that if Ctemp is the new Clocal, then immediately after the Ctemp $x line, $x should hold whatever flavor of undef is appropriate. snip Is there some reason we're huffmannizing snip Because 90% of the code that people use local for in perl 5 is for counting levels and automatically unwrapping them. The other 10% are for more complex values. Make me believe your 90/10 numbers. -Scott -- Jonathan Scott Duff [EMAIL PROTECTED]
Re: 'temp $x;' with no assignment
On Mon, Mar 27, 2006 at 14:54:05 -0600, Jonathan Scott Duff wrote: Make me believe your 90/10 numbers. http://cpansearch.bulknews.net/ is broken right now... =( -- Yuval Kogman [EMAIL PROTECTED] http://nothingmuch.woobling.org 0xEBD27418 pgpCMeQfldQFY.pgp Description: PGP signature
Re: 'temp $x;' with no assignment
On Mon, Mar 27, 2006 at 02:54:05PM -0600, Jonathan Scott Duff wrote: : On Mon, Mar 27, 2006 at 10:46:02PM +0200, Yuval Kogman wrote: : On Mon, Mar 27, 2006 at 14:35:52 -0600, Jonathan Scott Duff wrote: : I think that if Ctemp is the new Clocal, then immediately after the : Ctemp $x line, $x should hold whatever flavor of undef is appropriate. : snip : Is there some reason we're huffmannizing : snip : : Because 90% of the code that people use local for in perl 5 is for : counting levels and automatically unwrapping them. The other 10% are : for more complex values. : : Make me believe your 90/10 numbers. Doesn't matter what the numbers are, it's the right thing to do. The default undef hack stems from the days when local() was trying to fill the role of my() as well. Nowadays temp() should just mean: Please arrange to restore yourself to your current value and nothing more. (Well, plus the notion that, when applied to a mutator, the save/restore instruction is passed on to the mutatee to save itself before the mutation, not after.) The p5-to-p6 translator will turn local $x; into temp undefine $x; Larry