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 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 scalars by putting curlies around them: my( $s, $t ); $s = { "value t is $t" }; $t = "xyz"; print $s(); Currently we also require the de-lazifying context to supply a postfix .() marker, but possibly that could be assumed in a string or numeric context. I really don't see much benefit in making it easier than that. Larry