TIP #436: IMPROVE TCLOO ISA INTROSPECTION =========================================== Version: $Revision: 1.3 $ Author: Donal Fellows State: Final Type: Project Tcl-Version: 8.6.5 Vote: Done Created: Tuesday, 30 June 2015 URL: https://tip.tcl-lang.org436.html Post-History: ------------------------------------------------------------------------- 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. ------------------------------------------------------------------------- TIP AutoGenerator - written by Donal K. Fellows