[chuck-users] quiting chuck from chuck and saving reference to function
Spencer Salazar
ssalazar at CS.Princeton.EDU
Wed Nov 8 03:41:07 EST 2006
On Nov 8, 2006, at 10:39 AM, altern wrote:
> The only difference between all those shreds is the action the need to
> perform so i wanted to declare a variable for each and pass it as a
> reference when sporking the shread.
>
> [...]
>
> But this is impossible then.
Au contraire! As Ge mentioned, you can achieve the same result using
polymorphic inheritance. Practically, this would mean defining an
abstract base class like this:
class OscAction
{
fun void action() { }
}
and then, for each actual action, define a corresponding subclass
that "overloads" the action function:
class QuitAction extends OscAction
{
fun void action() { Machine.crash(); }
}
class DoSomethingElseAction extends OscAction
{
fun void action() { /* do something else */ }
}
Define oscshred like this:
fun void oscshred( OscEvent e, OscAction a )
call
spork ~ oscshred( quit_osc, new QuitAction );
to start up the quit listener and then call a.action() to actually
execute the action when you receive the appropriate OSC message.
hope this helps/makes sense.
> is it possible to receive arrays?
no... when support for strings improves, it would be possible to
transform arrays into strings and then send those, but right now that
is not possible so far as I am aware.
> is it possible to check for the beginning of the address and redirect
> the rest?
No, not at the moment... CNMAT (OSC's creator) says that OSC supports
this, and chuck uses CNMAT's OSC implementation, but perhaps chuck is
doing something wrong that ends up disabling this functionality.
spencer
More information about the chuck-users
mailing list