has_cvar

Gamma: Version 4.0
Prev |  | Next

# `has_cvar`

`has_cvar` -- queries for the existence of a class variable.

## Syntax

    has_cvar (instance|class, variable)

## Arguments

`instance`|`class`

  An instance of a class; or a class.

`variable`

  An class variable name, as a symbol.

## Returns

t if any instance, class or any parent (base) class contains the variable, otherwise nil.

## Description

This function checks for the existence of class variables for a class or instance of a class. It searches all parent (base) classes.

## Example

| This example is based on the class and method developed in `method` and `class_add_cvar`. The variable name is preceded by # to prevent evaluation. See Quote Operators for more information.

        Gamma> RegPolygon;
        #0=(defclass RegPolygon nil [(linethickness . 2) (perimeter . (defun RegPolygon.perimeter (self) (* (@ self sides) (@ self length))))][length sides])
        Gamma> polyD;
        {RegPolygon (length) (sides)}
        Gamma> Square;
        (defclass Square RegPolygon [(area . (defun Square.area (self) (sqr (@ self length))))][length (sides . 4)])
        Gamma> sqB;
        {Square (length) (sides . 4)}
        Gamma> has_cvar(RegPolygon, #linethickness);
        t
        Gamma> has_cvar(polyD, #linethickness);
        t
        Gamma> has_cvar(Square, #linethickness);
        t
        Gamma> has_cvar(sqB, #linethickness);
        t
        Gamma>

## See Also

`class_add_cvar`

Prev | Home | Next
`getprop` | Up | `has_ivar`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.