TIP 436: Improve TclOO isa Introspection

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2017 Conference, Houston/TX, US, Oct 16-20
Send your abstracts to tclconference@googlegroups.com
by Aug 21.
State:		Final
Type:		Project
Tcl-Version:	8.6.5
Vote:		Done
Post-History:	
Author:		Donal Fellows <dkf@users.sf.net>
Created:	30-Jun-2015

Abstract

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.

Rationale

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.

Copyright

This document has been placed in the public domain.

History