• set var in interactive tclsh vs set var in a script

    From Oleg Nemanov@21:1/5 to All on Tue Apr 26 07:15:37 2022
    Hi, all.

    I can't understand why in interactive tclsh a var has more refcount, then
    in a script:

    ~$ cat t.tcl
    set a [list 1 2]
    puts [::tcl::unsupported::representation $a]
    ~$ tclsh t.tcl
    value is a list with a refcount of 2, object pointer at 0x55e14c5c0f90, internal representation 0x55e14c5ce140:(nil), no string representation
    ~$ tclsh
    % set a [list 1 2]
    1 2
    % puts [::tcl::unsupported::representation $a]
    value is a list with a refcount of 3, object pointer at 0x55c8e66ab140, internal representation 0x55c8e66c2ae0:(nil), string representation "1 2"
    %

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Tue Apr 26 17:52:44 2022
    Am 26.04.2022 um 16:15 schrieb Oleg Nemanov:
    Hi, all.

    I can't understand why in interactive tclsh a var has more refcount, then
    in a script:

    ~$ cat t.tcl
    set a [list 1 2]
    puts [::tcl::unsupported::representation $a]
    ~$ tclsh t.tcl
    value is a list with a refcount of 2, object pointer at 0x55e14c5c0f90, internal representation 0x55e14c5ce140:(nil), no string representation
    ~$ tclsh
    % set a [list 1 2]
    1 2
    % puts [::tcl::unsupported::representation $a]
    value is a list with a refcount of 3, object pointer at 0x55c8e66ab140, internal representation 0x55c8e66c2ae0:(nil), string representation "1 2"
    %


    Dear Oleg,
    that is due to the history package.
    Each interactive result value is stored in the history.
    This increases the ref count.

    Hope this helps,
    Harald

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Oleg Nemanov@21:1/5 to All on Wed May 4 01:33:12 2022
    вторник, 26 апреля 2022 г. в 18:52:48 UTC+3, Harald Oehlmann:
    Dear Oleg,
    that is due to the history package.
    Each interactive result value is stored in the history.
    This increases the ref count.

    Thanks for the info! This helped me solve my problem :-).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)