text: Author: Colin McCormack <[email protected]> Author: Don Porter <[email protected]> Author: Kevin B. Kenny <[email protected]> State: Final Type: Project Vote: Done Created: 06-Aug-2008 Post-History: Tcl-Version: 8.6
  Abstract
  A number of Tcl's built-in commands currently raise errors when given arguments that would cause them to do nothing. This proposal asks that they instead simply do nothing gracefully.
  Rationale
  With the introduction of {*} syntax in Tcl 8.5 and its ability to convert one original word into zero words when an empty list is expanded, scripts using the syntax are forced to check for the empty list when passing expanded arguments to a command taking variable numbers of arguments, but arbitrarily rejecting zero arguments. For example,
  variable {*}$dict
  will currently fail if $dict has no entries. Letting no-ops simply be no-ops rather than errors greatly lightens the programming burden on callers. There may be some marginal performance benefits as well.
  Furthermore, there is no sound reason to constrain the argument count of these commands to be positive when an argument count of zero has a natural interpretation as a no-op. There is an elegance in permitting a function to range coherently over the complete domain.
  Proposal
  The syntax of the following commands shall be revised as described:
  file delete - accept zero pathnames.
  file mkdir - accept zero directories.
  global - accept zero variable names.
  glob - accept zero patterns, returning list of zero matching files (with -nocomplain) or "no matches" error.
  lassign - accept zero variable names.
  linsert - accept zero elements.
  lrepeat - accept both number = 0 and zero elements.
  my variable - accept zero variable names.
  namespace upvar - accept zero variable names.
  tcl::tm::path add - accept zero paths.
  tcl::tm::path remove - accept zero paths.
  variable - accept zero variable names.
  Compatibilty
  The proposed changes convert errors into no-ops. There should be no compatibility concerns with those.
  Implementation
  When an implementation patch is completed, it will be logged in the SF Tracker and noted here.
  Exclusions
  Some other candidates for this treatment are intentionally left out of this proposal where for various reasons their conversion is complicated in some way, or the benefits of conversion are not as clear cut. These other commands might still be revised in a similar way, but are left for other TIPs to accomplish it so that this TIP can focus only on the low-hanging fruit.
  after idle
  dict exists
  dict set d val (no key argument)
  dict unset d val (no key argument)
  dict update d script (no key varName arguments)
  eval
  expr
  file join
  interp eval
  namespace eval
  parray This feature request is more about tolerating errors than about expanding acceptance over a complete input domain. Not in the spirit of this TIP.
  uplevel
  upvar - presence of the optional level argument makes this one messy.
  Epilogue
  Proposed changes to string first, string last, and string replace in earlier revisions of the TIP that were approved by the vote have been rescinded after testing during the implementation phase revealed greater than expected issues with the incompatibilities those changes introduced.
  This document has been placed in the public domain.