Previous Next Table of Contents

2. Class creation syntax.

The class creation syntax in Xbase++ is slightly different to that used with Class(y). Some of the differences are documented in the Xbase++ manual but for completeness I'll outline those, and other, differences.

2.1 CREATE CLASS

The Class(y) syntax for starting a class definition is:

CREATE CLASS <class>

In Xbase++ it is simply:

CLASS <class>

Also, Class(y) allows you to inherit using either the keywords FROM or INHERIT, as in:

CREATE CLASS XbasePlusPlus FROM Clipper

CREATE CLASS XBasePlusPlus INHERIT Clipper

Xbase++ only allows for the FROM form of the syntax.

All of these differences are easily handled with the following pre-processor directives:

#xcommand CREATE CLASS <x>             => CLASS <x>
#xcommand CREATE CLASS <x> FROM <y>    => CLASS <x> FROM <y>
#xcommand CREATE CLASS <x> INHERIT <y> => CLASS <x> FROM <y>

[TODO: The METACLASS clause]

[TODO: The class function]

2.2 END CLASS

Xbase++ doesn't like to find a space in the End Class directive. This is easily solved with:

#xcommand END CLASS [<*x*>] => ENDCLASS

2.3 MESSAGE x METHOD y

The syntax for having a "message" call a method of a different name is different in Xbase++. In Class(y) you would do:

MESSAGE Foo METHOD MyFoo

but in Xbase++ you do:

METHOD Foo IS MyFoo

Again, this can be solved with the use of the pre-processor:

#xcommand MESSAGE <x> METHOD <y> => METHOD <x> IS <y>

2.4 MESSAGE x IS DEFERRED

Xbase++ uses a slightly different syntax when declaring a deferred method. With Class(y) you would use:

MESSAGE Foo IS DEFERRED

in Xbase++ you use:

METHOD Foo IS DEFERRED

The pre-processor directive:

#xcommand MESSAGE <x> IS DEFERRED => METHOD <x> IS DEFERRED

solves this problem.

2.5 [CLASS] VAR x TYPE y

Class(y) allows a form of strong typing for instance variables, Xbase++ does not support this. A simple fix for this incompatibility is to use the pre-processor:

#xcommand VAR <x> [<ro:READONLY>] TYPE <y>       => VAR <x> <ro>
#xcommand CLASS VAR <x> [<ro:READONLY>] TYPE <y> => CLASS VAR <x> <ro>

2.6 VISIBLE:

Class(y) provides the VISIBLE command to for symmetry with the HIDDEN command and it is little more than an alias for EXPORT. You can fix this with the pre-processor:

#xcommand VISIBLE: => EXPORT:


Previous Next Table of Contents