[chuck-users] Is there plans for something like "include"

Mike McGonagle mjmogo at gmail.com
Thu Jan 5 14:47:35 EST 2006


Thanks, Ge.

Is it possible to have a class in one file that extends another class
from another file? Basically, I would like to put the base class for
my fractal generators (I decided to go this route, even though the
generated data stream is different from the original C generated data)
into one file, while the actual fractal classes would extend the base
class in another file.

Mike


On 1/5/06, Ge Wang <gewang at cs.princeton.edu> wrote:
> Hi Michael!
>
> > I was wondering if there were plans to implement a method for
> > "including" a file in another? Something on the order of C's include,
> > or Java's import?
>
> There are plans (and even some implementation) for a name-based automatic
> file look-up (similar to Java class resolution).  It is currently on hold
> to make way to implement other features.  We have yet to invent/purloin
> a package-level include mechanism.  It (or another include/import method)
> will make its way into the language (in a few months hopefully).
>
> > Basically, I have some objects, that I would like to work with accross
> > several files. and rather than having to explicitly put the code into
> > each file.
>
> So far, there is the following (ghetto) method:
>
> 1. each .ck may contain one 'public' class (like java) - put important
> classes into their own .ck files (as 'public class').
>
> 2. 'running' such a .ck file will add the class to the type system, which
> subsequent code can instantiate.
>
> For example:
>
>    foo.ck : contains public class Foo definition
>    bar.ck : cotnains public class Bar definition
>    par.ck : uses Foo and Bar
>
> as long as foo.ck and bar.ck gets compiled/run before par.ck, things
> should work:
>
>    > chuck foo bar par
>
> 3. instead of running foo and bar on the command line every time, you can
> write one addition .ck file which runs the dependencies:
>
> // run foo.ck bar.ck
> machine.add( "foo.ck" );
> machine.add( "bar.ck" );
> // etc...
>
> if you want, you can also add par.ck from this file so you end up running
> one .ck file.
>
> 4. caveats:
> - currently, once a public class is added, it lives in the global
> namespace and can not be modified/removed.
> - machine.add( ... ) happens explicitly at runtime and is different from
> a static include.  therefore putting machine.add( "foo.ck" ) at the top
> of a program (par.ck) that uses Foo does not work.
>
> Again, this method is really ghetto, but we hope it helps.
>
> Best,
> Ge!
> _______________________________________________
> 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