[chuck-users] cross-referenced classes?

Robert Poor rdpoor at gmail.com
Fri Mar 13 12:46:39 EDT 2009


How absolute the knave is!  We must speak by the card, or equivocation  
will undo us!

Thanks.

- Rob

On 13 Mar 2009, at 09:01, Kassen wrote:

> 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;
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users



More information about the chuck-users mailing list