Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 8c8247f3e91945d796bdea036c226346337d88c4fcf45557f17a886f2a5f41f8
Ticket: e38dce74e28420b6c1f44fba604c4ed6193a6391
Command line built with list not properly quoted
User & Date: oehhar on 2024-09-18 17:42:26
Changes

  1. icomment:
    Hi Schelte, Hi Jan,
    I did not know, that this is valid to name a command with leading "#".
    For me, the quoting for a list is ok.
    The following snippet returns ##foo for 8.6 and 9.0
    
    <verbatim>
    proc {##foo} {args} {puts !}
    set cmd ##foo
    set args {}
    set c [list {*}$cmd {*}$args]
    lindex $c 0
    </verbatim>
    
    IMHO it is "interesting" to include the special syntax of a command in a list quoting.
    The list behaves differently than "[]".
    Really interesting and amazing...
    
    TCL 8.6 and 9.0 are identical here for me:
    
    <verbatim>
    % proc {##cmd} {args} {puts !}
    % ##cmd
    % {##cmd}
    !
    % set cmd ##cmd
    ##cmd
    % list $cmd
    {##cmd}
    % puts {*}$cmd
    ##cmd
    % puts [{*}$cmd]
    !
    </verbatim>
    
    So, the [$cmd] with cmd = ##cmd calls the command - weired !
    
    The use case by Schelte is, that a command would call the command in one case, but not in the other.
    
    Ok, lets try:
    
    <verbatim>
    proc {##foo} {args} {puts !}
    set cmd ##foo
    set args {}
    set c [list {*}$cmd {*}$args]
    lindex $c 0
    </verbatim>
    
    On 8.6:
    <verbatim>
    % eval $c
    !
    % puts [$c]
    invalid command name "{##foo}"
    </verbatim>
    
    On 9.0:
    <verbatim>
    % eval $c
    % puts [$c]
    !
    </verbatim>
    
    That is weired big fun !
    
    Thank you for all,
    Harald
    
  2. login: "oehhar"
  3. mimetype: "text/x-fossil-wiki"
  4. username: "oehhar"