Re: Can a scalar be lazy ?

2005-08-23 Thread Yuval Kogman
a correct answer. : : So I wonder, If we can make $scalar lazy also. As array now is lazy by default. : : Even if making scalar lazy might cause problem sometimes, Is it : possible to add a property which is like : my $var is lazy; to handle these situation? In Perl 6 you make lazy

Re: Can a scalar be lazy ?

2005-08-23 Thread Larry Wall
right thing. : : we have to use other way or eval '$s' before print to get a correct answer. : : : : So I wonder, If we can make $scalar lazy also. As array now is lazy by default. : : : : Even if making scalar lazy might cause problem sometimes, Is it : : possible to add a property which

Re: Can a scalar be lazy ?

2005-08-23 Thread Yuval Kogman
On Tue, Aug 23, 2005 at 10:56:08 -0700, Larry Wall wrote: We could probably extend is cached to attributes (and their implied accessors) if lazy blocks aren't sufficient. Hmm... With the whole distinction of foo as a value and foo() as a application of the value, maybe we can sometimes assign

Can a scalar be lazy ?

2005-08-22 Thread Yiyi Hu
my( $s, $t ); $s = value t is $t; $t = xyz; print $s; in perl 5, it will give a warning, and won't do right thing. we have to use other way or eval '$s' before print to get a correct answer. So I wonder, If we can make $scalar lazy also. As array now is lazy by default. Even if making scalar

Re: Can a scalar be lazy ?

2005-08-22 Thread Ingo Blechschmidt
Hi, Yiyi Hu wrote: my( $s, $t ); $s = value t is $t; $t = xyz; print $s; in perl 5, it will give a warning, and won't do right thing. we have to use other way or eval '$s' before print to get a correct answer. So I wonder, If we can make $scalar lazy also. As array now is lazy by default

Re: Can a scalar be lazy ?

2005-08-22 Thread Luke Palmer
On 8/22/05, Yiyi Hu [EMAIL PROTECTED] wrote: my( $s, $t ); $s = value t is $t; $t = xyz; print $s; I have an answer for you that is much more detailed than what you want to hear. The short answer is yes. This is possible to implement, provided you appropriately declare $t. It all depends on

Re: Can a scalar be lazy ?

2005-08-22 Thread Larry Wall
On Tue, Aug 23, 2005 at 04:09:29AM +0800, Yiyi Hu wrote: : my( $s, $t ); $s = value t is $t; $t = xyz; print $s; : in perl 5, it will give a warning, and won't do right thing. : we have to use other way or eval '$s' before print to get a correct answer. : : So I wonder, If we can make $scalar

Re: Can a scalar be lazy ?

2005-08-22 Thread Andrew Rodland
On Monday 22 August 2005 04:25 pm, Larry Wall wrote: On Tue, Aug 23, 2005 at 04:09:29AM +0800, Yiyi Hu wrote: [stuff] : Even if making scalar lazy might cause problem sometimes, Is it : possible to add a property which is like : my $var is lazy; to handle these situation? In Perl 6 you make