Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ddd9fb9e4bbac60a22312664e0a1fb4962b1e296
Ticket: 2251175fffffffffffffffffffffffffffffffff
Expand ({*}), constants, and list syntax
User & Date: lars_h on 2008-11-09 21:14:04
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    The syntax {*} uses when reparsing a literate constant appears to deviate from the usual list syntax in that it does not perform backslash substitution.
    
    Short example:
    % set L1 [list \{] ; # List intrep
    \{
    % set L2 {\{} ; # No intrep
    \{
    % set L3 [list {*}$L1 {*}$L2 {*}{\{} {*}"\\\{"]
    \{ \{ {\{} \{
    
    In all of these cases, the string being reparsed by {*} has a backslash as first character and a left brace as second character (i.e., the canonical string representation for the length 1 list whose only element is the left brace), but when that string is brace-delimited then something goes horribly wrong; it appears the {*} list parser thinks the backslash is just an ordinary character:
    
    % set L4 {{a b} {\\} \\ "c \n d"}
    {a b} {\\} \\ "c \n d"
    % list {*}$L4 {*}{{a b} {\\} \\ "c \n d"}
    {a b} {\\} \\ {c 
     d} {a b} {\\} {\\} {c \n d}
    
    This may have been supported by the following language in the dodekalogue:
    [5] Argument expansion. If a word starts with the string {*} followed by a non-whitespace character, then the leading {*} is removed and the rest of the word is parsed and substituted as any other word. After substitution, the word is parsed again without substitutions, and its words are added to the command being substituted.
    
    That is not consistent with TIP#157 however, since this clearly specifies the {*}-reparsing as "After substitution, the word is then parsed as a _list_ (as if with Tcl_SplitList() or Tcl_GetListFromObj)". Backslash substitution is a necessary part of list syntax, since the string representation for list elements which are not balanced with respect to braces requires backslash substitution. 
    
    I also note that there doesn't seem to be any tests for {*} which involves applying it to lists with a string reperesentation that contains backslashes.
    
    
    
  4. foundin changed to: "obsolete: 8.6a3"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "lars_h"
  10. subsystem changed to: "45. Parsing and Eval"
  11. title changed to: "Expand ({*}), constants, and list syntax"
  12. type changed to: "Bug"