Overview
| Artifact ID: | 6150e8d61cfd1a34770a3243bbc6c1ef6b738b60 |
|---|---|
| Ticket: | 1062849fffffffffffffffffffffffffffffffff
EXPR with single substitution |
| User & Date: | alove on 2004-11-09 04:01:07 |
Changes
- assignee changed to: "dkf"
- cmimetype changed to: "text/plain"
- comment changed to:
SUMMARY: The EXPR command in its regular form performs two substitutions: one by the Tcl parser and one by the EXPR command itself. But in practice, the TCL parser is rarely needed; almost all EXPR commands are coded with double-braces to improve performance. This is a main contributor to what is known as "quoting hell" when using TCL: set var [expr {$a*25}] set speed [expr {($a+$b)/75}] create line [expr {$a+2}] [expr {$a2+7}] \ [expr {$a+$bh-2}] [expr {$b2+$a+3}] Rather than using more quotes to give a single substitution and more speed, I propose a new command called XP, which is identical to EXPR with double braces. Using this command, the above code would look like this: set var [xp $a*25] set speed [xp ($a+$b)/75] create line [xp $a+2] [xp $a2+7] \ [xp $a+$bh-2] [xp $b2+$a+3] The third line saves 16 characters of typing, including eight double-braces that require the shift key. IMPLEMENTATION: This command would be identical to EXPR except that it would skip the TCL parser. For demonstration, you can simulate the command (but not its speed) using proc xp {a} { eval expr { $a } } (This proc works only if you exclude spaces from the expression, which is why the above examples have no spaces.) - foundin changed to: "None"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "alove"
- subsystem changed to: "16. Commands A-H"
- title changed to: "EXPR with single substitution"
- type changed to: "RFE"