has_ivar (instance|class, variable)
An instance of a class; or a class.
An instance variable name, as a symbol.
t if the instance or class contains the named instance variable, or if any parent (base) of the class contains the instance variable, otherwise nil.
This function queries an instance or class to determine whether a given instance variable exists for that instance or class. When querying classes, if any parent (base) of that class contains the given instance variable, this function returns t. It is possible for a class to contain an instance variable, and an instance of that class not to contain it, but only if class_add_ivar was called after the instance was created. See class_add_ivar for details.
This example is based on the class and method developed in method. The variable name is preceded by # to prevent evaluation. See Quote Operators for more information. |
Gamma> Square; (defclass Square RegPolygon [(area . (defun Square.area (self) (sqr (@ self length))))][length (sides . 4)]) Gamma> sqB; {Square (length) (sides . 4)} Gamma> has_ivar(Square, #sides); t Gamma> has_ivar(Square, #perimeter); nil Gamma> has_ivar(sqB, #area); nil Gamma> has_ivar(sqB, #length); t Gamma>
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.