It would be great if ChucK could include other .ck files. I know you can do machine.add("foo.ck"), but it would be great if we could do it with non-shreds as well. For example, I could have a bunch of functions which I could then include in other projects. You can't machine.add a fun float changevalue ( float foo ) { ... return bar; } Technically speaking, whatever.include("foo.ck"); would simply insert the contents of foo.ck into the original file at the place where whatever.include() was called. Cheers, - Graham
Hi Graham,
For example, I could have a bunch of functions which I could then include in other projects. You can't machine.add a fun float changevalue ( float foo ) { ... return bar; }
No, but you can make a public class that has these functions in it. public class x{ fun float changeval(float foo){return bar;} }//eof machine.add("myclass.ck"); x instanceOfX; instanceOfX.changeval( yourGreatData ); .. This works quite well. Then you can make a file like classloader.ck that is just a bunch of machine.add() and when you write a new class you drop it into the classloader.ck file and you always have your handy dandy classes ready to go. --art
No, but you can make a public class that has these functions in it.
public class x{
fun float changeval(float foo){return bar;}
}//eof
machine.add("myclass.ck");
This works, except that machine.add() only adds the file after you've executed the code, which means you can't yet use the 'x' class in the same file. however, you should be able to do so in subsequent files. So: %> chuck TheClass.ck [other files that use TheClass] or %> chuck Loader.ck [other files that use files loaded in Loader.ck] And of course you can add classes and files that use them with on-the-fly commands: terminal 1: %> chuck --loop terminal 2: %> chuck + TheClass.ck %> chuck + ClientCode.ck We are still working on the include problem. Using explicit (precessor) includes can be problematic - since there are no separate headers, mutual usage is precluded, and there are other complications too, such as cycles and uh... The current ChucK framework is moving towards a system similiar, but not identical, to Java (scan, automatically search/load by class/filename) and even matlab (yay?). This is a high priority but may take a while to converge on a useful resolution. I hope we will continue thinking and posting on this... Best, Ge!
participants (3)
-
Adam R. Tindale
-
Ge Wang
-
Graham Percival