Tcl and lazy evaluation

Jan 06, 2010 17:05

(1) tclsh8.6 [~] time {::tcl::mathop::** 24234234234 3}
48 microseconds per iteration
(2) tclsh8.6 [~] time {::tcl::mathop::** 24234234234 35}
64 microseconds per iteration
(3) tclsh8.6 [~] time {::tcl::mathop::** 24234234234 356}
751 microseconds per iteration
(4) tclsh8.6 [~] time {::tcl::mathop::** 24234234234 3567}
27330 microseconds per iteration
(5) tclsh8.6 [~] time {set r [::tcl::mathop::** \
24234234234 3567]}
25456 microseconds per iteration
(6) tclsh8.6 [~] time {puts $r}

1816843090540950601273121465948192432631624240736883645173523455345029038294564975361519212256172666325678909567996308380933196797483967816332138611210928183939533791487558019191039300817104711925146928329667522361955640589545337337930872465752414412052834040712735517549435...7485779545559864262353678231936739970095213019398144
16544733 microseconds per iteration

Just "calculation" (4) is a little bit longer than "calculation plus assignment" (5), but the output (6) is the longest operation. Does Tcl really use some kind of lazy evaluation?

tcl

Previous post Next post
Up