WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
[access] [class_mod] CLASS name[<T[(constraints)], ...>] [EXTENDS class] & [IMPLEMENTS interface, ...][INHERITS [class,] [interface[, ...]]] member_def . . . ENDCLASS
(optional) One of the following access modifiers:
Access is not restricted. This is the most accessible option. (default)
Access is limited to the containing class or types derived from the containing class.
Access is limited to the containing type. This is the least accessible option.
Access is limited to the current assembly. (Synergy .NET only)
Access is limited to the current assembly and types derived from the containing class. (Synergy .NET only)
(optional) One or more of the following class modifiers:
The class cannot be instantiated.
The class is restricted to CLS public members. (Synergy .NET only)
The class definition can be separated into two or more definitions that will be compiled together as a single definition.
The class cannot be extended.
The class is implicitly sealed, which means you cannot derive from it. Only STATIC members are allowed in a STATIC class.
The name of the class to define.
A generic type parameter, which indicates the class is a generic type and which acts as a placeholder for which an actual type will be substituted when the member is used. Note that you can use any unused letter (not just T). See Generic types (.NET) for more information. (Synergy .NET only)
One or more of the following constraints:
- A base class, to stipulate that the generic type parameter must inherit from that specific base class. If no base class is specified, the default is System.Object.
- One or more interfaces, to stipulate that the generic type parameter must implement the specified interfaces.
- A constructor, to allow creating an instance of the type parameter using the NEW syntax.
Multiple constraints must be separated by commas. See Constraints for more information. (Synergy .NET only)
(optional) The class will extend the specified parent class and will thus inherit members from that parent class. See the Discussion for more information.
(optional) Specifies one or more interface names to implement. Multiple interfaces must be separated by commas.
The declaration of a method, function, subroutine, field, property, indexer, structure, operator, delegate, enumeration, event, or nested class within the class. You can specify as many member definitions as you want, although you must specify at least one.
INHERITS [class][, interface]
(optional) Specifies the name of one parent class from which the class inherits and/or one or more interface names to implement. If the interface is preceded by a class name, it must also be preceded by a comma. Multiple interfaces must be separated by commas. We recommend that you use EXTENDS and/or IMPLEMENTS instead of INHERITS, which is only supported for code conversion purposes. (Synergy .NET only)
The CLASS-ENDCLASS statement declares a class in the current namespace or within another class.
SEALED and ABSTRACT are mutually exclusive. Typically, an ABSTRACT class contains one or more abstract methods and/or properties. Abstract methods can only exist in abstract classes.
Using the PARTIAL modifier, it is possible to split the definition of a class over two or more source files. Each source file contains part of the class definition, and all of these parts are combined when your application is compiled, as long as no syntax errors or naming collisions exist in the partial class declarations. You may want to split a class definition when working on a large project, for example, to enable multiple developers to work on different parts of the class simultaneously. Partial classes must be compiled together at the same time (as a single compilation unit); they can’t be split across compilation units.
If the EXTENDS option is not specified, the compiler assumes the parent class is the System.Object class (which is the ultimate parent class of all objects). When a class extends a parent class, it inherits the following members from the immediate parent class, as well as any members that the parent inherits from its parent, in recursive fashion:
- All methods (not constructors)
- All fields and properties
- All nested classes
If parent is a fully qualified class name, the class definition is implicitly imported.
Neither a common record nor a global data section may be declared within a class.
An interface enables you to define required features, avoid changes that can break your program, and enforce consistent class design throughout different implementations. A class member can implement an interface member if the following criteria are met:
- The class’s signature, including the return type, is the same as the interface member.
- The class has public accessibility.
- The class is non-static.
When you declare that a class implements an interface, that class, or one of its ancestors, must implement all members in the interface as well as any interfaces from which that interface inherits.
You can declare an explicit interface member by prefixing the interface name and a dot (.) to the class member name. This is particularly useful if a class implements more than one interface with the same member names that require different implementations. This rule applies to all interface members.
For example, you could declare a method that implements interface Iface.mymethod as follows:
public class class1 implements Iface public method Iface.mymethod, void proc mreturn endmethod endclass
Explicit interface members are only accessible via a variable of that interface type. For example, if you wanted to access Iface.mymethod, you would need to do the following:
var1, @Iface var1 = (Iface)obj var1.mymethod()
Nested classes have the same requirements as regular classes, with the following exceptions:
- A nested class cannot extend any of its outer classes.
- A nested class declaration can use an outer class for the following within the nested class declaration:
- Return types, argument types, or local variable types in methods
- Field and property types
- Nested classes are PRIVATE by default.
See Nested classes for more information.
In the example below, class3 accesses class2’s private member m_number.
class class2 class class3 public method writeit, void c2, @class2 proc open(1,o,"tt:") writes(1,"num="+%string(c2.m_number)) close(1) mreturn end endclass public method class2 proc m_number = 567 mreturn end private m_number, i4 endclass
The example below creates a custom attribute by extending System.Attribute and specifying the attribute’s usage by applying the AttributeUsage attribute to the new class.
[AttributeUsage(AttributeTargets.All)] public class MyAttribute extends System.Attribute public method MyAttribute parm1, string proc name = parm1 end private name, string endclass