[chuck-users] classes / bpm?

Kassen signal.automatique at gmail.com
Tue Oct 16 12:12:45 EDT 2007


On 10/16/07, Martin Ahnelöv <operagasten at gmail.com> wrote:

Since it's a public class, multiple shreds can access it. However, I
> don't really have an idea about how you do that. Please, kassen!
> Explain!
>

Well, you just execute the file that contains the public class in a VM.

>From then on, any chuck code that runs in that VM can instantiate objects of
that class.

example;

-----------B.ck----------------------
Foo bar;
<<<bar.value>>>;
--------------------------------------

-----------A.ck-------------------
public class Foo
{
23 => int value;
}
--------------------------

now B is only going to compile if you run A (and thus define Foo) first. Not
very hard, I'd say.



Also, no, currently chuck doesn't have a way to import libraries



True. If B.ck would read;
-------B.ck-----------------------
Macine.add("A.ck");
Foo bar;
<<<bar.value>>>;
  --------------------------------

It wouldn't work as B would be parsed (finding a undefined class) before A
would be Machine.added. So; one possible solution to this would be a
Machine.include() command that would see whether the classes in it's
argument are already defined, if not define those and only then parse the
rest of the file. That's not without problems as a way of fixing the issue
though and if available I'd support a more intelligent method.


Also, once added a public class can't be edited, for example to add some
feature to it, without restarting the whole VM.

Kas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20071016/aa8a6326/attachment.htm 


More information about the chuck-users mailing list