-/* usage of objects inside C<<1 program */
+/* usage of object community inside C<<1 program */
/* This is example of advanced C<<1 object oriented features... */
/* This is example of advanced C<<1 object oriented features... */
-def_type(Point);
-def_type(Shape);
-
-def_mem(PointInterface)
+def_interface(Point, PointInterface)
{
void method(move) (Shape self, int x, int y);
str method(desc) (Shape self);
{
void method(move) (Shape self, int x, int y);
str method(desc) (Shape self);
+def_interface(Shape, ShapeInterface)
void method(draw) (Shape self);
void method(draw) (Shape self);
- void method(move) (Shape self, int x, int y);
- str method(desc) (Shape self);
- void method(rename) (Shape self, str name);
void method(reset) (Shape self, int x1, int y1, int x2, int y2, int x3, int y3);
float method(area) (Shape self);
int count;
};
void method(reset) (Shape self, int x1, int y1, int x2, int y2, int x3, int y3);
float method(area) (Shape self);
int count;
};
-/* This is example of hierarchical object architecture in C<<1 */
+/* This is example of non-hierarchical object federation architecture in C<<1 */
def_obj(Point)
{
interface(PointInterface);
def_obj(Point)
{
interface(PointInterface);
+ shape Shape; /* this is optional, but we will use it do demonstrate power of C<<1 */
construct(Tri,ShapeInterface) (Tri self, int x1, int y1, int x2, int y2, int x3, int y3)
{
construct(Tri,ShapeInterface) (Tri self, int x1, int y1, int x2, int y2, int x3, int y3)
{
+ self->point = confederate_obj(Point);
+ _(move, self->point, x1, x2);
self->name = "TRIANGLE";
interface_of(self)->count++;
self->name = "TRIANGLE";
interface_of(self)->count++;
- _(reset, self, x1, y1, x2, y2, x3, y3);
+ _(reset, self, x2, y2, x3, y3);
def_obj(Animal)
{
interface(Actions);
def_obj(Animal)
{
interface(Actions);
};
construct(Animal,Actions) (Animal self, str name)
};
construct(Animal,Actions) (Animal self, str name)