Skip to main content

Top Level Class Syntax

Describes the structure of a class definition. See Class Definitions for links to general information on defining classes.

Introduction

In InterSystems IRIS, a class can include familiar class elements such as properties, methods, and parameters (known as constants in other class languages). It can also include items not usually defined in classes, including triggers, queries, and indexes.

A class definition defines a class. A class definition consists of class members (such as properties and methods) and other items, called keywords, each with associated values, that specify details of the class behavior.

Details

A class definition has the following structure:

Import import_ppackage_list  
Include include_code  
IncludeGenerator include_generator_code  

/// description 
Class package.shortclassname Extends superclass_list [ class_keyword_list ] 
{  
Class_members
  [Parameter]
  [Property]
  [Method]
  [Foreign Key]
  [Index]
  [Projection]
  [Query]
  [Storage]
  [Trigger]
  [XData Block]
}

Where:

  • import_package_list (optional) specifies the names of any packages that you wish your class to import from. This affects how the compiler resolves short class names; see Importing Packages.

    This option, if specified, is either the name of a single package or is a comma-separated list of multiple packages, enclosed in parentheses.

    If import_package_list is null, do not add the Import line at the start of the class definition.

    Note:

    If a class imports any packages, that class does not automatically import the User package.

    Imported packages are inherited from all superclasses. If a subclass specifies one or more import packages, those are added to any import packages defined by the superclasses.

  • include_code (optional) specifies InterSystems IRIS include (.inc) files used when compiling this class.

    This option, if specified, is either the name of a single include file (without the .inc extension) or is a comma-separated list of multiple include files, enclosed in parentheses.

    If include_code is null, omit the Include line at the start of the class definition.

    For an introduction to include files, see Include Files in the InterSystems Programming Tools Index.

    Include files are inherited from all superclasses. If a subclass specifies one or more include files, those are added to any include files defined by the superclasses.

  • include_generator_code (optional) specifies InterSystems IRIS include (.inc) files used when compiling the generator methods for this class. For information on generator methods, see Defining Method and Trigger Generators.

    For general comments, see the previous item.

    If include_generator_code is null, do not add the IncludeGenerator line at the start of the class definition.

  • description (optional) is intended for display in the Class Reference. A description may consist of multiple lines and may include HTML formatting tags and additional tags such as <class> and <method>. For limitations and details, see Creating Class Documentation. The description is blank by default.

  • package (required) is a valid package name, as described in Package Names.

  • shortclassname (required) is a valid class name. Together, package and shortclassname form the complete class name, which is subject to a length restriction. See Naming Conventions.

  • superclass_list (optional) specifies the class or classes from which this class inherits. This option, if specified, is either the name of a single class (without the .cls extension) or is a comma-separated list of classes, enclosed in parentheses.

    The first such class is referred to as the primary superclass; any additional classes are secondary superclasses. For information, see Inheritance.

    If superclass_list is null, omit the word Extends from the class definition.

  • class_keyword_list (optional) is a comma-separated list of keywords that (in most cases) affect how the compiler generates code for this class definition.

    See Class Keywords for a complete keyword list.

    If this list is omitted, also omit the square brackets.

  • Class_members is zero or more definitions of class members.

    For an introduction, see Kinds of Class Members. See the following sections in this reference for details on class members:

See Also

FeedbackOpens in a new tab