has_ivar
has_ivar — queries for the existence of an instance variable.
has_ivar (instance|class, variable)
instance|classAn instance of a class; or a class.
variableAn 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 |
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);tGamma>has_ivar(Square, #perimeter);nilGamma>has_ivar(sqB, #area);nilGamma>has_ivar(sqB, #length);tGamma>