[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Lazy Evaluation question (was: Anybody look at Ruby?)



John Carter wrote:

> Does [Ruby] have Lazy evaluated parameters?

Does Perl?  I guess a reference to a closure that returns a scalar
would pass correctly, but would it evaluate without some syntax?

Testing:

perl -e '$clo = sub {2 + ++$tally}; $r = \$clo ; print $r, $r'

references to SCALAR

perl -e '$clo = sub {2 + ++$tally}; $r = \$clo ; print &$r, &$r'

references to scalars are not executable

perl -e '$clo = sub {2 + ++$tally}; $r = \$clo ; print $$r, $$r'

references to CODE


perl -e '$clo = sub {2 + ++$tally}; $r = \$clo ; print &$$r, &$$r'

works


i wonder how much trouble a LAZY type would be to create, which
would appear to the rest of the syntax as a scalar, but only get
evaluated when it is evaluated.  Like C<time>.

Is that on anyone's to-do list?

Are there really situations in which you need lazy evaluation without
knowing about it deeply enough in advance to wrap and unwrap the
closures?



Or have I totally misunderstood what "lazy evaluation" is?




___________________________________________________________________
                           David Nicol 816.235.1187 nicold@umkc.edu
                "A laser that generates a beam of pure anti-matter"

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe