[chuck-users] cross-referenced classes?

Kassen signal.automatique at gmail.com
Fri Mar 13 12:01:47 EDT 2009

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.


==========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()
            second => now;
            !state => state;
            engine.control( maybe );

Controller boss;
Engine motor;
boss $ Foo @=> motor.controller;
motor $ Foo @=> boss.engine;

hour => now;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20090313/88e2e1b6/attachment.htm>

More information about the chuck-users mailing list