Deutsch   English   Français   Italiano  
<1036dd3$13c9j$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Christian Gollwitzer <auriocus@gmx.de>
Newsgroups: comp.lang.tcl
Subject: Re: a typeof command for debugging?
Date: Sat, 21 Jun 2025 15:51:31 +0200
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <1036dd3$13c9j$1@dont-email.me>
References: <10364a2$11i1c$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 21 Jun 2025 15:51:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c43880425a29be66687deed006bc9c56";
	logging-data="1159475"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18XsS3V7CoDjD2jplLThNQrvLyjkShF4pg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:QRE6A37S5dlsclO6T3vnFzAudlg=
In-Reply-To: <10364a2$11i1c$1@dont-email.me>

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