Skip to content
Tcl Source Code History Of Ticket 217994
Login

History Of Ticket 217994

Artifacts Associated With Ticket 217994

  1. Ticket change [53e3d3bbb1] (rid 93837) by nobody on 2000-10-26 00:51:47:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 639 Bug
      Version: 8.0
      SubmitDate: '1998-05-25'
      LastModified: '1999-08-14'
      Severity: MED
      Status: Closed
      Submitter: hershey
      ChangedBy: hobbs
      OS: All
      OSVersion: NA
      Machine: NA
      FixedDate: '2000-10-25'
      FixedInVersion: NA
      ClosedDate: '1999-08-14'
      
      
      Consider the following commands in TCL 8.0p2:
      
      % expr 8 + ""
      syntax error in expression "8 + "
      % expr "" + 8
      8
      %
      % expr "" > 10
      syntax error in expression " > 10"
      % if { "" > 10 } { puts true }  else { puts false }
      false
      
      
      Granted, the above code is somewhat strange, but realize that the ""
      could be the return result of any other command such as:
      
      if { [ myCustomCmd arg1 arg2 ] > 10 } { puts true }
      
      
      In general, the fact that TCL does not handle NULL values in its
      expression evaluation causes tremendous headaches.
      
      TCL handles NULL STRINGS such as:
      
      string index "" 9
      
      But returns errors whenever a NULL value is encountered in an
      expression.
      
      Many languages will simply return NULL if an expression
      contains any type of NULL value in it.  It would be very nice if
      TCL would do the same.
      
      I have created a GUI builder that uses TCL as its scripting
      language.  Each field on my screen can have TCL methods associated
      with it.  We have extended TCL to provide a "getfld" and a
      "setfld" command that retrieves/sets the value contained in the field
      on the screen. We would like to simply write code as appears below:
      
      setfld Field1 [ expr [ getfld Field2 ] + [ getfld Field3 ] ]
      
      Unfortunately, we had to create another command called "checkfld"
      that first makes sure the field is not NULL before attempting to
      evaluate the expression:
      
      if { [checkfld Field2 Field3] } {
         setfld Field1 [ expr [ getfld Field2 ] + [ getfld Field3 ] ]
      }
      else {
         setfld Field1 ""
      }
      
      This might not seem too bad but its alot of work to simply add
      2 numbers together and it means that every single time we
      refer to a field on our GUI we need to first make sure its not
      NULL.
      
      We could modify our code to not allow NULL values on our screen
      and force all numeric fields to zero but this would not make a
      very friendly GUI - you need to allow blank numeric fields on
      any GUI.
      
      We have also noticed that the expr "" + 8 command behaves differently
      between TCL 7.3 and TCL 8.0.
      
      So my question is:
      
      Why not change the expr command to return a NULL value when any
      argument in its expression list is NULL?  Other commands that
      take expressions such as "if { expression } " could easily
      be written to make NULL expressions behave the same as FALSE
      expressions.
      
      Thank you for reading this far.  Please let me know if there is
      any hope for this request.
      
      
      Chris Handorf
      602-914-8116
      Motorola SPS
      Phoenix, AZ
      [email protected]
      
      These are programming misunderstandings.  The changes to expr
      are well defined in the porting docs, and expr expressions should
      now always be {}ed for proper evaluation (and speed).
      The error reporting is correct.  For each case:
      
        % expr 8 + ""
        syntax error in expression "8 + "
      
      Here the user receives an error because the binary op + is unsatisfied
      
        % expr "" + 8
        8
      
      Here the user isn't using braces, so the Tcl level of eval converts
      this to just "+ 8", and then expr uses the + as a unary op.
      
        % expr "" > 10
        syntax error in expression " > 10"
      
      > is never a unary op...
      
      % if { "" > 10 } { puts true }  else { puts false }
      false
      
      This works, because the initial use of a string is kicking this
      into the string comparison mode.  A command should not be used
      in this way if it isn't guaranteed what type of arg would be
      received.  Use string compare/equal or fix the command. 
      -- 08/14/1999 hobbs
      
    4. foundin initialized to: "obsolete: 8.0"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "69. Other"
    10. title initialized to: "Null expressions"
    11. type initialized to: "Bug"
  2. Ticket change [74a00be369] (rid 105236) by welch on 2000-10-26 08:12:10:

    1. closedate changed to: "2000-10-26T01:12:10"
    2. closer changed to: "welch"
    3. priority changed to: "2"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"
  3. Ticket change [0d490562ee] (rid 114337) by dgp on 2001-04-14 03:46:04:

    1. closedate changed to: "2001-04-13T20:46:04"
    2. closer changed to: "dgp"
    3. foundin changed to: "obsolete: 8.0p2"
    4. resolution changed to: "Invalid"
    5. subsystem changed to: "16. Commands A-H"