Skip to main content

Specifying Method Keywords

Specifying Method Keywords

In a method definition, you can include optional compiler keywords that affect how the method behaves. The following list shows some of the most commonly seen method keywords:

In InterSystems IRIS, methods can be written in ObjectScript or Python. To specify which language you will write a method in, use the following syntax:

Method MyMethod() [ Language = objectscript ]
{
    // implementation details written in ObjectScript
}
Method MyMethod() [ Language = python ]
{
    # implementation details written in Python
}

If a method does not use the Language keyword the compiler will assume that the method is written in ObjectScript.

You must write the method’s language in all lowercase letters, as in the example.

This keyword specifies that the method is private and can only be used with ObjectScript methods. Subclasses inherit the value of the Private keyword and cannot override it.

By default, methods are public and can be accessed anywhere. You can mark a method as private (via the Private keyword). If you do:

  • It can only be accessed by methods of the class to which it belongs.

  • It does not appear in the InterSystems Class Reference.

It is, however, inherited and available in subclasses of the class that defines the method.

Other languages often call such methods protected methods.

FeedbackOpens in a new tab