Classes are objects in Green. The
code
class Figure
public:
proc init( x : integer; y : integer )
proc draw()
...
end
is a class declaration. This class is used to create objects
of Figure. The object representing
class Figure is declared as
object Figure
public:
proc getMaxWidthFigure() : integer
...
...
end
and will be called "class object Figure".
This example defines an object as in delegation-based languages in which
classes do not exist.
The constructor of a class is always
called init. For each method init
of a class the compiler creates a new
method in the class object that calls the class init
method. So, class object Figure
has a method
new( x : integer; y : integer )
Therefore, one can write
var f : Figure;
f = Figure.new( 5, 20 );