Here we go; this works; the controller sends commands to the engine, the engine executes those but depends on the state of the controller for the final result. there is a issue where the classes need to be defined above the actual code. This is no real issue when working with multiple files and public classes but I still think it's against the language specs. This is probably another example of the bug that creates a need for classes that extend Event to be defined above the spot where we use broadcast or signal on them.
Cheers,
Kas.
==========example code below================
//we need to define the classes at the top or the casting will fail
//I considder this to be a bug.
class Foo
{
fun void control( int message)
{
}
fun int querry ()
{
return false;
}
}
class Engine extends Foo
{
Foo controller;
fun void control ( int message)
{
<<<message + controller.querry()>>>;
}
}
class Controller extends Foo
{
Foo engine;
int state;
spork ~ work();
fun int querry()
{
return state;
}
fun void work()
{
while(1)
{
second => now;
!state => state;
engine.control( maybe );
}
}
}
Controller boss;
Engine motor;
boss $ Foo @=> motor.controller;
motor $ Foo @=> boss.engine;
hour => now;