SourceForge.net Class Specification

Class Specification
Table of Contents

How to declare a class


Classes are defined within a euclass/end euclass structure, similar to a routine. Within the euclass/end euclass, data members and methods may be defined. Members may be defined anywhere in a class specification (i.e., they can appear after methods are defined. Members may be of any type, including other classes. The class data type must be a sequence if you define any data members, because the members are elements in the sequence. In fact, the preprocessor simply maps these to constants, which are used to subscript the class instance.

Classes which are derived from other classes inherit all methods and members. You can overload methods. It is possible, though questionable, to duplicate an inherited member. The member that was the last declared will always have precedence. The only way to access the inherited member is to explicitly subscript (see section on Dot Notation).

You can specify the return type of a member function by adding a colon (':') followed by the type after the function name. This will be used for polymorphism purposes when a member function is used as an argument for another method call.

global euclass ClassName( ClassDataType x )
	MemberDataType m
	
  function ClassName() : ClassName

  end function

	function fMethod() : sequence
	
	end function
	
	function fMethod( atom a ) : atom
	
	end function
	
	procedure pMethod()
	
	end procedure	

end euclass

ClassName instance
instance = SomeValue

instance.pMethod( instance.fMethod( instance.fMethod() ) )
To create an instance of a class, declare a variable with the type of the class:
  ClassName aClassNameInstance
You may also declare variables (and members) as 'sequence of' a class type. This allows you to refer to elements in the sequence as instances of the specified class:
  sequence of SomeClass s
    -- ...
  s[1].Method()