List Info

Thread: Deferred variable bindings, part 3/3




Deferred variable bindings, part 3/3
country flaguser name
Switzerland
2007-08-24 04:30:22
This finishes the implementation of deferred variable
bindings, allowing 
code like this:

Eval [
     PackageLoader fileInPackage: 'Iconv'.
     I18N.EncodedStream blahblah
]

which previously was not allowed, because I18N was not
declared at the 
beginning of the eval.

It is probably now time to say that implicit temporaries
cost a lot in 
terms of performance, and this only got worse with deferred
variable 
bindings:

Eval [ Time millisecondsToRun: [ 1000000 timesRepeat: [ x :=
5 ]]]
918

However, you can recover performance by using a temporary
inside an Eval:

Eval [ | x | Time millisecondsToRun: [ 1000000 timesRepeat:
[ x := 5 ]]]
116

Using a temporary in the inner block:
Eval [ Time millisecondsToRun: [ | x | 1000000 timesRepeat:
[ x := 5 ]]]
104

Using a temporary that disables compiler optimization of
#timesRepeat:
Eval [ Time millisecondsToRun: [ 1000000 timesRepeat: [ | x
| x := 5 ]]]
314


Note that temporaries outside Evals are ignored; otherwise
the nice 
behavior of temporaries persisting through different
invocations would 
not be possible.

Paolo

_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

  
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )