TIP #436: Improve TclOO isa Introspection

Title:Improve TclOO isa Introspection
Version:$Revision: 1.3 $
Author:Donal Fellows <dkf at users dot sf dot net>
Created:Tuesday, 30 June 2015


The various info object isa introspectors should not produce errors when given a non-object; the set membership tests should simply return boolean false in those cases.


The info object isa command is intended to be used to allow asking whether some object is a member of a general set of entities; for example, info object isa object allows querying whether you actually have a handle to an object at all. However, the other membership sets all throw an error when given a non-object. This complicates the use of the API when all that is really needed is to return a false value in those cases.

Motivating example (with thanks to Will Duquette): is the proc a class? No. It's not even an object, so it clearly cannot be a class and so the following command should produce false (or 0) and not an error:

 info object isa class proc

Proposed Change

Where one of the info object isa introspectors:

Would produce an error due to either the object or (where appropriate) the class object not passing some critical precondition to the test, the result of the command will be 0 (i.e., boolean false). Errors will be still generated when the wrong number of arguments are supplied.

Note that this rule is already followed by info object isa object.


This document has been placed in the public domain.

Powered by Tcl[Index] [History] [HTML Format] [Source Format] [LaTeX Format] [Text Format] [XML Format] [*roff Format (experimental)] [RTF Format (experimental)]

TIP AutoGenerator - written by Donal K. Fellows