TIP #436: Improve TclOO isa Introspection


TIP:436
Title:Improve TclOO isa Introspection
Version:$Revision: 1.3 $
Author:Donal Fellows <dkf at users dot sf dot net>
State:Final
Type:Project
Tcl-Version:8.6.5
Vote:Done
Created:Tuesday, 30 June 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.


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