Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages
icioo(1) FreeBSD General Commands Manual icioo(1)

icioo - ICI object-oriented programming

<I>This page is out of date. A whole new OO mechanism has been available since ICI 3.0.</I>
Ici's support for object-oriented programming is very simple. Inheritance is already provided through the ability to extend one structure's scope by defining a super structure for it. This can be done either with the notation:

static my_instance = [struct:my_parent x, y ];
or with the functional notation

static my_instance = super(my_parent, x, y);
although it's probably better to set up an atomic (`class') variable for the super structure, and use that:

to refer to an atomic (unchanging) version of your `class' struct.
The method call is achieved by an extension of the normal function call operator "()". When the "()" operand is a function identifier, the function is called in the usual way with the supplied parameter list. But if the "()" operand is a pointer object keyed by a function identifier, the function is called with the object pointed-to passed as an implicit first parameter.
The binary operator `@' forms such a pointer from an aggregate object (usually a struct) and an identifier (i.e. a member of the struct). This is the same basic technique used for dynamic dispatch in languages like Smalltalk and Objective-C.
Here is a little example showing a few ways this can be used. Note the occasional use of literal functions.
showtype(any, label)
    printf("%s is a %s\n", label, typeof(any));
/* * Class definition. */ static Point = [struct p_x = 0.0, p_y = 0.0, p_swap = [func (self) { self.p_x <=> self.p_y; } ], p_print = [func (s) { printf("Pt <%g %g>\n", s.p_x, s.p_y);} ], p_what = showtype, ];
static p1 = struct(@Point); /* Set super struct to be atomic Point */
p1.p_x = 1.2; p1.p_y = 3.4;
p1@p_what("p1"); p1@p_print(); p1@p_swap(); p1@p_print();
Which produces this output when run:
p1 is a struct Pt <1.2 3.4> Pt <3.4 1.2>
In summary, method calls depend on:
Ici's super linkage to provide the normal OO inheritance name search mechanism.
The `@' binary operator to form a keyed pointer that will select the named member of the struct.
The "()" (call) operator's special treatment of a function-keyed pointer.
The syntax is the natural result of using ici's normal language facilities.

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.