TIP #436: Improve TclOO isa Introspection
_____________________________________________________________________________
TIP:	436
Title:	Improve TclOO isa Introspection
Version:	$Revision: 1.3 $
Authors:	Donal Fellows <dkf@users.sf.net>
State:	Final
Type:	Project
Tcl-Version:	8.6.5
Vote:	Done
Created:	Tue Jun 30 00:00:00 UTC 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:
info object isa class object
info object isa metaclass object
info object isa mixin object class
info object isa object object
info object isa typeof object class
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.
_____________________________________________________________________________
Colophon
TIP AutoGenerator - written by Donal K. Fellows