• Funny TCL and C api missing access to namespace variable.

    From aotto1968@aotto1968@t-online.de to comp.lang.tcl on Fri Jan 3 11:55:38 2025
    From Newsgroup: comp.lang.tcl


    Tcl has a C api … good

    1) for *namespace* -> man Tcl_CreateNamespace ...
    2) for *set at variable* -> man Tcl_ObjSetVar2 ...

    but tcl has *no* C-Api to access a namespace variable :-)

    to access a namespace variable in "C" you have to construct the variable-name-string fist .. like:

    Tcl_Obj* myO = Tcl_ObjPrintf("%s::%s", ns_cstr, var_cstr)
    (by the way the "Tcl_ObjPrintf" missing format specifier for "Tcl_Obj*")

    and than use the *string* to access the variable;

    Tcl_ObjSetVar2(interp,myO,?array-key or NULL?,newVal,flags)

    The funny thing is that the "TclObjLookupVar" always disassemble the "myO" string
    to figure out the namespace/array-key etc…

    To make it short, Tcl need a *better* Tcl_Set/GetVar??? api perhaps "3" with namespace,variable,arrayItem separated to speedup access.

    Tcl_ObjSetVar3(interp,myNs,myVar,myKey,newObj,flags)

    and SKIP the parsing of "myVar" for either myNs or myKey.

    The problem is NOT the 1-time access of a variable because the variable is AFTER
    access cached, the problem is the *multiple* access with either *namespace* or *varname* is very dynamic.


    → just a "hint"


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Rich@rich@example.invalid to comp.lang.tcl on Fri Jan 3 13:12:33 2025
    From Newsgroup: comp.lang.tcl

    aotto1968 <aotto1968@t-online.de> wrote:

    To make it short, Tcl need a *better* Tcl_Set/GetVar??? api perhaps
    "3" with namespace,variable,arrayItem separated to speedup access.

    Write up a TIP and supply an implementation and your request might be
    accepted into the Tcl core.
    --- Synchronet 3.20a-Linux NewsLink 1.114