Call functions from other files
Hello, I'd like to create some files with simple functions and call them in a Main.ck file. I try with Machine.add or spork, but these properties are a different way. There is any function as in C (#include ) or python (import file)? Thanks Again, -- Claudio Rogerio
Hi Claudio, That sounds like a job for classes in ChucK. If you’re familiar with object oriented programming, you’ll find that it handles this type of scenarios pretty well. Depending on how you are setting up your project, you should be able to simply add the class to the virtual machine (+), or using Machine.add(). The following link should be helpful: http://chuck.cs.princeton.edu/doc/language/class.html http://chuck.cs.princeton.edu/doc/language/class.html Best, JP
On 25/08/2019, at 9:22 AM, Claudio Rogerio
wrote: Hello,
I'd like to create some files with simple functions and call them in a Main.ck file. I try with Machine.add or spork, but these properties are a different way.
There is any function as in C (#include ) or python (import file)?
Thanks Again,
--
Claudio Rogerio _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
I've been hoping for namespaces and imports in ChucK for a long time https://github.com/ccrma/chuck/issues/109 https://github.com/ccrma/chuck/issues/109 The workaround as JP mentions is to Machine.add all the ChucK files you might need. LiCK contains a rather long one https://github.com/heuermh/lick/blob/master/import.ck https://github.com/heuermh/lick/blob/master/import.ck michael
On Aug 24, 2019, at 6:00 PM, JP Yepez
wrote: Hi Claudio,
That sounds like a job for classes in ChucK. If you’re familiar with object oriented programming, you’ll find that it handles this type of scenarios pretty well. Depending on how you are setting up your project, you should be able to simply add the class to the virtual machine (+), or using Machine.add().
The following link should be helpful:
http://chuck.cs.princeton.edu/doc/language/class.html http://chuck.cs.princeton.edu/doc/language/class.html
Best,
JP
On 25/08/2019, at 9:22 AM, Claudio Rogerio
mailto:claudioufpa@gmail.com> wrote: Hello,
I'd like to create some files with simple functions and call them in a Main.ck file. I try with Machine.add or spork, but these properties are a different way.
There is any function as in C (#include ) or python (import file)?
Thanks Again,
--
Claudio Rogerio _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu mailto:chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
My solution for module loading for this is similar to the LiCK
implementation, but slightly neater and easier to scan/extend/script imho:
// _boot.ck
[
"InputProvider",
"RealtimeState",
"RealtimeJob",
"ScanState",
"ScanSystem"
] @=> string libs[];
for (int i; i < libs.cap(); i++) {
Machine.add(libs[i]);
}
// eof
On Sun, 25 Aug 2019 at 06:21, Michael Heuer
I've been hoping for namespaces and imports in ChucK for a long time
https://github.com/ccrma/chuck/issues/109
The workaround as JP mentions is to Machine.add all the ChucK files you might need. LiCK contains a rather long one
https://github.com/heuermh/lick/blob/master/import.ck
michael
On Aug 24, 2019, at 6:00 PM, JP Yepez
wrote: Hi Claudio,
That sounds like a job for classes in ChucK. If you’re familiar with object oriented programming, you’ll find that it handles this type of scenarios pretty well. Depending on how you are setting up your project, you should be able to simply add the class to the virtual machine (+), or using Machine.add().
The following link should be helpful:
http://chuck.cs.princeton.edu/doc/language/class.html
Best,
JP
On 25/08/2019, at 9:22 AM, Claudio Rogerio
wrote: Hello,
I'd like to create some files with simple functions and call them in a Main.ck file. I try with Machine.add or spork, but these properties are a different way.
There is any function as in C (#include ) or python (import file)?
Thanks Again,
--
Claudio Rogerio _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (4)
-
Anthony Bowyer-Lowe
-
Claudio Rogerio
-
JP Yepez
-
Michael Heuer