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 : 21. Jun 2025, 14:51:31
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <1036dd3$13c9j$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
Am 21.06.25 um 13:16 schrieb Mark Summerfield:
I'd like a `typeof` command for debugging.
I've had a go but only bits of it work.
 ```
     proc typeof x {
         if {![catch {[info object class $x] name}]} {
             return $name
         } else {
             if {[string is boolean -strict $x]} {
                 return bool
[...]
I don't think you can do much better than that, since Tcl is a weakly typed language (usually referred to as the "EIAS" principle). The only other thing you can do is peek into the internal cached type, which shows you the last type that was used on that object (besides string):
(chris) 50 % set a [expr {23*5}]
115
(chris) 51 % tcl::unsupported::representation $a
value is a int with a refcount of 4, object pointer at 0x55d6b8f8b320, internal representation 0x73:(nil), string representation "115"
          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