Implementing an object-oriented model in a structured programming language.

So-o defines a functional layer which adds an object-oriented programming model to a structured programming language. Inspired by Smalltalk, So-o is complete, simple and light, easy to understand.

So-o proposes a standard implementation in several languages. The code in PHP is less than a 1000 lines.

namespace Hello;

require_once 'So-o.php';

defclass('Hello', null, 1, null, null, null, array('hello'));

function i_hello($self) {
    echo 'Hello from So-o!', PHP_EOL;

    return $self;

Defines the class Hello which inherits from the default class Object. Its revision number is 1. It adds no class or instance properties. It adds no class methods. It adds an instance method called hello.

The function i_hello defined in the Hello namespace implements the instance method called hello. $self is the instance which has received the hello message.

$ php -a
php > require_once 'Hello.php';
php > $hello=sendmsg($Hello, 'new');
php > sendmsg($hello, 'hello');
Hello from So-o!

Loads the code for the Hello class. Sends the message new to the Hello class. The new method is implemented by the Object class. It returns a new instance of the class. Sends the message hello to the $hello instance.



To add a comment, click here.