Basically, on rare occasions, sometimes my scripts add blank lines to a file, pretty sure I know how to fix that, but is there a way to count all the lines in the file, but tell it to ignore empty lines. Thanks.
When a procedure is invoked, the procedure's return value is the value specified in a return command. If the procedure doesn't execute an explicit return, then its return value is the value of the last command executed in the procedure's body.
Making the last returned value inside the proc be the contents of the variable. (set returns the value of the variable when called with one argument) If we were to remove the 'set' line, an empty string would be returned (the value returned by 'close')
Get it?
Last edited by user on Mon Sep 01, 2003 4:13 am, edited 1 time in total.
% set aa 1
1
% proc dd {} { global aa; return $aa }
% set bb [time dd]
66 microseconds per iteration
% proc dd {} { global aa; set aa }
% set bb [time dd]
45 microseconds per iteration
% info patchlevel
8.4.4
% set aa 24
24
% proc dd {} {global aa; return $aa}
% time dd
36 microseconds per iteration
% proc dd {} {global aa; set aa}
% time dd
30 microseconds per iteration
While it is closer, the 'set' method still appears to be a tad faster. (atleast in this situation)
has variable substitution AND a command invocation. So that pretty much explains where the extra cpu cycles go.
The command invocation is "compiled away" in the lastest version as you mentioned though, but apparently the two methods are still not equally demanding on the cpu. This must be because variable substitution is slower than command invocation in this particular case.