Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ae9d0a3b9447186af35f7251258780e9a7be52d781b281180d4c0163c82c17d0
Ticket: f8a20dff9c1b3259c08f3b8b7539c199a5b8a0ee
Doc: description of command "variable" incomplete
User & Date: oehhar on 2026-06-03 13:54:01
Changes

  1. comment changed to:
    The description of the command "variable" [https://www.tcl-lang.org/man/tcl9.0/TclCmd/variable.html] gives the synopsis:
    
    <verbatim>
    variable name
    variable ?name value...?
    </verbatim>
    
    I don't know what this means.
    
    The described form is:
    
    <verbatim>
    variable name ?value?
    </verbatim>
    
    Unfortunately, the command accepts 0 to infinite arguments. Only 1 or 2 arguments do something:
    
    <verbatim>
    % namespace eval test {variable v1 c1 c2 c3}
    % set test::v1
    c1
    </verbatim>
    
    What is this for:
    <verbatim>
    % namespace eval test {variable}
    </verbatim>
    
    This is probably due to the fact, that in OO context, the command has a totally different syntax (Ashoks book, page 394):
    
    <verbatim>
    variable ?SLOTOPERATION? ?VARNAME ...?
    </verbatim>
    
    The same command "variable v1 c1" means different things:
       *   in namespaces, a namespace variable v1 is set to c1
       *   in OO, the variables v1 and c1 are defined as class variables.
    
    Great !
    
    I would love, if the command:
    
      *   would give a propper error message, if used in the different contextes.
      *  the documentation would document all this strange stuff.
    
    Sorry for my OO unskill  level, it is all strange.
    
    Take care,
    Harald
    
  2. login: "oehhar"
  3. mimetype: "text/plain"