[chuck-users] cross-referenced classes?
Robert Poor
rdpoor at gmail.com
Fri Mar 13 10:56:19 EDT 2009
Hi Kas:
My fault for not pointing this out: one contained a reference to the
other, not an instance.
But even when both are references, ChucK still won't compile it.
Imagine you had a "controller" object that controls an "engine"
object, but the engine needs a reference back to the controller, e.g.
to query its state. This is a standard programming pattern. Here's
how I would express it (and lose):
=================
[file: controller.ck]
public class Controller {
Engine @ engine;
}
[file: engine.ck]
public class Engine {
Controller @ controller;
}
% chuck controller.ck engine.ck
[controller.ck]:line(2): undefined type 'Engine'
=================
There must be some ChucK-ish idiom that I don't yet understand.
- Rob
On 13 Mar 2009, at 04:35, Kassen wrote:
> Rob;
>
>
> How does one compile cross-referenced classes?
>
> Wait. Let me get this straight; you want a "scratch" to contain a
> "sniff" and a "sniff" should in turn contain a "scratch"? Yet that
> "scratch" will contain another "sniff" and that "sniff" will contain
> a "scratch" and that "scratch" will contain another "sniff" and that
> "sniff" will contain a "scratch" and that "scratch" will contain
> another "sniff" and that "sniff" will contain a "scratch" and that
> "scratch" will contain another "sniff" and that "sniff" will contain
> a "scratch" and that "scratch" will contain another "sniff" and that
> "sniff" will contain a "scratch" and that "scratch" will contain
> another "sniff" and that "sniff" will contain a "scratch" and that
> "scratch" will contain another "sniff" and that "sniff" will contain
> a "scratch" and that "scratch" will contain another "sniff" and that
> "sniff" will contain a "scratch" and that "scratch" will contain
> another "sniff" and that "sniff" will contain a "scratch" and this
> will go on forever? Is that correct?
>
> I think I'm going to have to agree with Tom here; you shouldn't do
> that.
>
> Let's take a step back and look at what you are actually trying to
> accomplish, practically speaking, and see how we could go about that.
>
> Yours,
> Kas.
>
> _______________________________________________
> 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