[chuck-users] can there be many ::ms in while?

Martin Ahnelöv operagasten at gmail.com
Fri Aug 3 04:59:38 EDT 2007

fre 2007-08-03 klockan 07:14 +0000 skrev Stephen Ball:
> just to chime in here - i'm VERY new to programming. how do you create
> this kind of concurrency? if, say, you wanted to create two while
> loops, but wanted them to run "side-by-side", but looping at different
> speeds, how would you do it?
> for example:
> while (true){ do something; 100::ms => now;}
> and
> while (true) {do something else; 150::ms => now;}

Yes, you can do that. FYI, it's called threading in traditional
programming languages and is often a pain in the ass, but since chuck
isn't a traditional language it's called sporking and is as simple as
running a chuck file.

I don't know how you create your patches and run them on your system,
but I am a command-line person, so when I start coding in chuck, I open
a command-line and type "chuck --loop". Then I open another command-line
and create/dig out my patch and I run it with "chuck + patch.ck".

Notice how the first command-line with chuck --loop tells us that we
have added a file? Good.

Now I'll create another patch with the second while-loop. I add it to
the virtual machine (the chuck --loop) with another "chuck + patch2.ck".

If you already got both of them done, you can play them synced with the
command "chuck patch.ck patch2.ck"

You can also do sporking in the code, but I haven't looked at that
enough - it's in the help pages, though.

Hope that helps,

ps. look at the on-the-fly-commands.

More information about the chuck-users mailing list