Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 70754312697fac55f3c35e32d0bf1f38b6b6a56d
Ticket: 218505ffffffffffffffffffffffffffffffffff
The interface to Tcl_EvalObjv is not that great
User & Date: nobody on 2000-10-26 01:01:25
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 739 Bug
    Version: 8.1a2
    SubmitDate: '1998-10-15'
    LastModified: '1999-02-01'
    Severity: MED
    Status: Released
    Submitter: welch
    ChangedBy: stanton
    OS: All
    OSVersion: NA
    Machine: NA
    FixedDate: '1999-02-01'
    FixedInVersion: 8.1b1
    ClosedDate: '2000-10-25'
    
    
        The current (public CVS 8.1 snapshot) implementation of Tcl_EvalObjv() in
    
    generic/tclParse.c is optimized for use by internal Eval family of routines.
    
    Yet it is a "public" API entry point, and as such should be optimized for
    
    the needs of extension writers.
    
    
        The most likely use of Tcl_EvalObjv by extension writers is likely along
    
    the lines of my (long ago) "leval" proposal: basically one or more of the
    
    extension commands constructs a new command from some of its arguments, but
    
    instead of being passed as a string to the traditional Tcl_Eval(), the command
    
    is directly evaluated with the specified objc/objv[].
    
    
        So far so good and the Tcl_EvalObjv() API supports this, but it
    
    does not generate stack trace information for the generated command, and
    
    requires the caller to supply the command source string for command traces
    
    (and again but outside Tcl_EvalObjv for stack traces in errorInfo).
    
    
        Also the extension writer does not know when the string is actually needed,
    
    since it is only used for command traces and error traces, neither of which
    
    typically happen.  So he ends up computing (if he is careful enough to supply
    
    a non-empty source string) strings which largely go unused.
    
    
        This seems (to me at least) to be an unnecessary burden.  The caller
    
    has no source string, because as an extension writer, he was not parsing
    
    commands, just constructing argument lists.  And the intent for bypassing
    
    "eval" is to avoid the overhead (and possible information loss) when
    
    converting all the arguments to strings and back.
    
    
        To make the extension writers job easy I propose that the string
    
    generation for command traces and stack traces be part of Tcl_EvalObjv()
    
    and the "command" and "numBytes" arguments be dropped from the public API.
    
    
        The original function can be renamed to EvalObjv() and become static
    
    in tclParse.c, or if one day needed in other modules, can be renamed
    
    to TclEvalObjv() and declared in tclInt.h.
    
    
        Attached is an implementation (in the form of a patch).  It also completely
    
    incidentally adds a missing "}" in the var.test file.
    
    
        Given the new Tcl_EvalObjv() it is trivial to "objectify" "lsort -command"
    
    (the Syd Polk patch), or to implement "leval" where apart from performance
    
    and lossy float conversion the following are equivalent:
    
    
    A.  leval arg1 arg2 ... arg2
    
    
    B.  set cmd {}
    
        foreach arg [concat arg1 arg2 ... argn] {
    
    lappend cmd $arg
    
        }
    
        eval $cmd
    
    
    
    
    I trust Viktor's argument here.  It makes sense to me.
    This procedure could be quite useful, and now is the time to adjust its API.
    The patch is  in the patch database.
    
  4. foundin changed to: "obsolete: 8.1a2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "10. Objects"
  10. title changed to: "The interface to Tcl_EvalObjv is not that great"
  11. type changed to: "Bug"