Is there plans for something like "include"
Hello everyone, 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? Also, if this is not in the plans, then is there anyone who is using something like either "m4" or C's preprocessor to merge file prior to "feeding" ChucK? Is there a way to "pipe" the preprocessed files into ChucK without having to write that stuff to another file? 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. Thanks, Mike
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!
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
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@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
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.
Yes it is possible. The parent class can be defined in its own file. After the file is compiled and run, the class should be available for subsequent programs to inherit/instantiate/use, as if the class were defined in the same file. Let us know if you run into issues doing this. Best, Ge!
On 1/5/06, Ge Wang
Yes it is possible. The parent class can be defined in its own file. After the file is compiled and run, the class should be available for subsequent programs to inherit/instantiate/use, as if the class were defined in the same file. Let us know if you run into issues doing this.
Thanks, I will have to rethink a little bit of how I arrange things. I was under the impression that I would have to put everything into one file... Mike
Best, Ge! _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- Help the Environment, Plant a Bush back in Texas!
participants (2)
-
Ge Wang
-
Mike McGonagle