Dcode
Dcode

Reputation: 223

Check Object Existence in TCL

I want to check that whether object exists or not in tcl. I looked into info object options but didn't found something specific for object existence and info exists only works for variables not objects.

Any idea? I created an object of struct::stack ::struct::stack aa (Dcode) 52 % info object class aa ::struct::stack::stack_oo

It seems that it is in tcloo. I think in Itcl find command works itcl::find object aa

But not aware of tcl_oo.

Upvotes: 2

Views: 1512

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137557

You probably just missed it: info object isa object is used to test whether a particular word refers to an object.

% info object isa object abcde
0
% oo::object create abcde
::abcde
% info object isa object abcde
1
% abcde destroy
% info object isa object abcde
0

Here, with some other commands…

% info object isa object oo::object
1
% info object isa object while
0
% info object isa object no.such.thing.at.all.ever
0

Upvotes: 3

Related Questions