|
2014-08-06
| ||
| 19:10 | • Ticket [820be4117d] Pre-decision of substitution of the command arguments / {sub... artifact: 4d95826e16 user: sebres | |
| 16:58 | • Closed ticket [820be4117d]. artifact: 4c6f0021e0 user: msofer | |
|
2014-05-21
| ||
| 18:12 | • Ticket [820be4117d]: 6 changes artifact: c53d1f289a user: dkf | |
| 10:31 | • Ticket [820be4117d]: 3 changes artifact: f5db3b78c9 user: sebres | |
| 10:29 | • New ticket [820be4117d]. artifact: cd823a4c14 user: sebres | |
Pre-decision of substitution of the command arguments / {substitute inside}
Closed / Rejected820be4117d621f80b756074f0f784840451d0143Created 13 years agoUpdated 12 years ago
Descriptionplain2014-05-21 10:29:47
I think, if by compiling a command we make possible to set a flag like TCL_SubstInside, that will be a great feature to minimize common overhead.
There are many cases where we could use this feature. For example logging in middle level, something like:
% log DEBUG $Cmd "execute statement: $statement, result: [res2str $res], ..."
To this effect, if DEBUG level is off, the substitution is totally needless.
Of course we could enclose it in braces (as below), and after verifying of level substitute in uplevel in log command:
% log DEBUG {$Cmd "execute statement: $statement, result: [res2str $res], ..."}
But, substitution in uplevel is not really good solution, imho, but at the moment only this solution is possible, to minimize overhead.
The logik bellow is not really solution also, because is too long also and if later I will change algorithn to check log-level I should change many lines of code:
% if {DEBUG ni $log::levels} {log DEBUG {$Cmd "..."}}
sebres Ticket [820be4117d]: 3 changes
[History diff]2014-05-21 10:31:48
dkfhtml2014-05-21 18:12:00
That makes it astoundingly hard to get the semantics right. For example, suppose you did:
log DEBUG $Cmd "execute statement $statement, result: [break]"In that case, the semantics of log don't matter as the break will take precedence.
Because of this complexity, I'd be inclined to reject this RFE. Leaving to Miguel to take the final decision.
Other logging frameworks in languages like Java have equivalent problems, and solve them by allowing probing of the log level. We could also take the message argument and do uplevel 1 subst on it if we're going to do the logging, allowing it to be quoted with {braces}, but that also doesn't require changes to Tcl's parse/compile semantics.
msoferplain2014-08-06 16:58:38
This requires a change in the basic rules in Tcl.n, so exceeds the scope of a simple RFE by several miles. I also agree with dkf (too much pain for little gain), and would likely oppose a TIP to this effect.
sebresplain2014-08-06 19:10:20
> log DEBUG $Cmd "execute statement $statement, result: [break]"
> In that case, the semantics of log don't matter as the break will take precedence.
@dkf: no really, cause this sould definitely substitute in current scope.
What I meant would be:
log DEBUG $Cmd {execute statement $statement, result: [break]}
So it is equivalent inside of proc "log":
# set msg {execute statement $statement, result: [break]}
...
if {$lev > $Level ...} {
set msg [uplevel [list if 1 [list subst $msg]]]
}
It is like this:
set msg {puts [incr i]--test}
set msg [uplevel [list if 1 [list subst $msg]]]
@msofer: I can write the solution, that would be not so painful.
Log in (anonymous is fine) to add a comment.