if { [ catch { foo new } ] } { source "path_to_code" }
您可以使用 info 命令:
info
if {![info object isa class foo]} {source "path_to_code"}