Tcl Source Code

View Ticket
Login
Ticket UUID: 1564517
Title: [expr]: handling of negative literals
Type: Bug Created on: 2006-09-24 13:16:19
Submitter: msofer Assigned to: dgp
Subsystem: 47. Bytecode Compiler Severity:
Priority: 5 Medium Last modified: 2007-08-17 02:19:51
Status: Closed Closed by: dgp
Resolution: Fixed Closed on: 2007-08-16 19:19:51
Version: None
Description:
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
User Comments:
dgp added on 2006-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.

dgp added on 2006-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.

dgp added on 2007-08-17 02:19:51:
Logged In: YES 
user_id=80530
Originator: NO


fixed in HEAD