modern Tcl and correct quoting
Poor Yorick
org.macosforge.lists.macports-dev at pooryorick.com
Wed Jun 12 22:01:40 PDT 2013
On Wed, Jun 12, 2013 at 10:18:54PM +0000, Poor Yorick wrote:
>
> Putting [expr] arguments in braces can result in much better performance as it
> allows Tcl to cache a byte-coded version of the expression. It can also avoid unintended processing that might occur via double substitution. Ref http://wiki.tcl.tk/10225.
>
> [eval] concatenates its arguments and passes them through the interpreter again
> to be parsed and executed as a script. This results in double substitution.
> Here's an example from the patch:
>
Another point about [eval] and braces is that passing it a single braced
argument rather than multiple arguments can result in a dramatic performance
gain due to bytecode caching and execution. This can be true also for [expr],
[if], and [while]:
Here's an example:
% info patchlevel
8.6.0
% time {eval incr i} 10000
2.374413 microseconds per iteration
% time {eval {incr i}} 10000
0.6567845 microseconds per iteration
--
Yorick
More information about the macports-dev
mailing list