Re: a typeof command for debugging?

Liste des GroupesRevenir à cl tcl 
Sujet : Re: a typeof command for debugging?
De : auriocus (at) *nospam* gmx.de (Christian Gollwitzer)
Groupes : comp.lang.tcl
Date : 22. Jun 2025, 20:22:37
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <1039l5t$n0a8$1@dont-email.me>
References : 1 2 3
User-Agent : Mozilla Thunderbird
Am 22.06.25 um 08:50 schrieb Mark Summerfield:
I found that tcl::unsupported::representation says "pure string" for
strings and numbers and bools and lists; it only seems to distinguish
dicts (Tcl 9.0.1).
No, it doesn't. You seem to have the misconception that {1 2 3} is a list of three values. It is actually a string, but can be treated as a list.
In Tcl, neither the values nor the variables do have a type in the sense of Python. However, the runtime uses an internal cached typed representation, which you can query.
See this transcript:
(chris) 49 % set a [list 1 2 3]
1 2 3
(chris) 50 % tcl::unsupported::representation $a
value is a list with a refcount of 4, object pointer at 0x5576f6d87430, internal representation 0x5576f6d57ab0:(nil), string representation "1 2 3"
(chris) 51 % set b [dict a 1 b 2]
b 2
(chris) 52 % tcl::unsupported::representation $b
value is a dict with a refcount of 4, object pointer at 0x5576f6d86e30, internal representation 0x5576f6da2d60:(nil), string representation "b 2"
(chris) 53 % set c [expr {1.0/3}]
0.3333333333333333
(chris) 54 % tcl::unsupported::representation $c
value is a double with a refcount of 4, object pointer at 0x5576f6d86cb0, internal representation 0x3fd5555555555555:(nil), string representation "0.33333333333..."
(chris) 55 % set d yes; if {$d} { puts yes }
yes
(chris) 56 % tcl::unsupported::representation $d
value is a booleanString with a refcount of 4, object pointer at 0x5576f6d880f0, internal representation 0x1:0x5576f6d815e0, string representation "yes"
(chris) 57 %
Read up on EIAS if you struggle to understand this. It is alos the reason why this is in the "unsupported" namespace, because this command breaks EIAS.
           Christian

Date Sujet#  Auteur
21 Jun 25 * a typeof command for debugging?8Mark Summerfield
21 Jun 25 `* Re: a typeof command for debugging?7Christian Gollwitzer
21 Jun 25  +- Re: a typeof command for debugging?1Christian Gollwitzer
22 Jun 25  `* Re: a typeof command for debugging?5Mark Summerfield
22 Jun 25   +* Re: a typeof command for debugging?2Ralf Fassel
22 Jun 25   i`- Re: a typeof command for debugging?1Mark Summerfield
22 Jun 25   `* Re: a typeof command for debugging?2Christian Gollwitzer
23 Jun 25    `- Re: a typeof command for debugging?1Christian Gollwitzer

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal