Tcl Library Source Code

View Ticket
Login
Ticket UUID: 3578420
Title: [exists] and colorful generator names
Type: Bug Version: None
Submitter: pooryorick Created on: 2012-10-19 18:20:53
Subsystem: generator Assigned To: tallniel
Priority: 5 Medium Severity:
Status: Open Last Modified: 2026-11-16 00:06:15
Resolution: None Closed By:
    Closed on:
Description:
[exists] is currently defined like this:

proc exists generator { expr {[llength [info commands $generator]] != 0} }

this could fail if $generator contains interpreted [string match] characters.  Also, the following fix is more performant (thanks kbk):

proc exists generator { expr {[namespace which $generator] ne {}} }
User Comments: serhiy.storchaka added on 2026-11-16 00:06:15:

Proposed fix in branch generator-exists-colorful-names: exists uses namespace which -command instead of passing the name to info commands as a pattern. Adds generator.test.