Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 96165454bd01453267f4da062e378f9e7f13f0fb
Ticket: 8e91ec4866db095f1d90d4e2fd468305a8a80bf8
{TCL LOOKUP VARNAME} vs {TCL READ VARNAME}
User & Date: aspect on 2015-07-24 02:51:38
Changes

  1. icomment:
    That distinction sounds very subtle to me.  Var structures aren't
    something I'm familiar with from the script level, and I'm not sure
    I should be!  It has struck me a few times, and anecdotally I have
    record of evilotto questioning the array behaviour on chat months 
    ago.
    
    For the array cases I can sort of understand (LOOKUP if the array
    doesn't exist; READ if the element doesn't), but the difference
    between the first two cases isn't obvious.  Is this interpreted vs
    bytecode paths?
    
    I don't see that the distinction aids the programmer to write
    correct code.  Both produce exactly the same error message, giving
    no hint that the difference exists, and when I want to trap one I
    practically always want to trap both, which requires two independent
    trap clauses and code duplication.  I think they should at least
    share a common prefix to facilitate this common case.
    
    Perhaps {TCL VARNAME READ} would have been a better structure, but I
    think that horse has bolted.  Perhaps we can salvage something in
    the form of {TCL LOOKUP VARNAME $varName $op} but that's starting to
    look pretty cumbersome.  {TCL LOOKUP VARNAME ?varName?} across the
    board seems pretty appealing to me right now.
    
    I could be convinced that it's useful to have distinct READ and
    LOOKUP error codes, but that moves the focus on to documentation.
    And this sounds like a right pain to explain to impatient novice
    programmers -- enough that I'd rather mess with code than prose ;-).
    
  2. login: "aspect"
  3. mimetype: "text/plain"