Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2007-08-17
02:19 • Closed ticket [1564517fff]: expr: handling of negative literals plus 8 oth... artifact: 74ffbe9f2c user: dgp
2006-09-27
22:24 • Ticket [1564517fff]: 4 changes artifact: ba9a4b1d85 user: dgp
2006-09-25
07:58 • Ticket [1564517fff]: 5 changes artifact: 811d8bf375 user: dgp
2006-09-24
13:16 • New ticket [1564517fff]. artifact: 60f2bbb188 user: msofer

[expr]: handling of negative literals

Closed / Fixed1564517fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 19 years ago
Descriptionplain2006-09-24 13:16:19
Negative numeric constants are stored as a positive
literal, and UMINUS is executed on it at runtime:

  Command 1: "expr {$v > -99}"
    (0) loadScalar1 %v0         # var "v"
    (2) push1 0         # "99"
    (4) uminus
    (5) gt

This can be very costly if happens in a loop (see 
http://groups.google.com/group/comp.lang.tcl/browse_frm/thread/b2a6592f802dfddc/82517b5f8bf2b145
dgpplain2006-09-25 07:58:18
Logged In: YES 
user_id=80530

I'd need to review the code
to recall the details and
rationale, but this is an
intentional feature of the
expr parser.
dgpplain2006-09-27 22:24:26
Logged In: YES 
user_id=80530


The expr parser has always
aggresively interpreted "-"
and "+" as operators.

Looking into what the compiler
can do to improve bytecode for
this situation.
dgpplain2007-08-17 02:19:51
Logged In: YES 
user_id=80530
Originator: NO


fixed in HEAD
Log in (anonymous is fine) to add a comment.