On Mon, Mar 05, 2012 at 05:41:47PM -0500, George Locke wrote:
Hi,
Hey George!
I want to make a library of functions that I can call from any chuck script. If I put those functions in one file, how do I access them from another? It would be great if I could make them into a new namespace, akin to Std.X or Math.X (I am using miniAudicle 0.2.0, not command line.)
Right now I'd say make a public class called -say- "Lib" and outfit it with static member functions that would be your "x". Then you'd add it using Machine.add(file_with_class.ck) at the start of your session. That way Lib.x() might be exactly equivalent to Math.x() in usage. The downside is the way of loading it, but after that it'd be essentially identical in usage.
(I checked the language specification for the words "include" and "import" and found nothing relevant.)
Yes, clearly the above is a workaround. People were working on exactly this functionality for library style functions. It hasn't been very busy on that front for a while, but recently things are picking up a bit again, I think.
PS is there a popular/built-in solution for making exponentially distributed, normally distributed, etc random variables?
There was something like that, I seem to remember, but I can't remember who did it. Clearly good tools for randomness would be a good idea, maybe even as a build-in library as randomness is quite fundamental to computer-music and synthesis and just having white-noise is a bit limited. We used to collect stuff at the Princeton CS wiki, where (generously) non-students (or students of other insitutions) could also have accounts, then there was a wave of spam and new accounts can no longer be casually created.
PPS If not, I'd be happy to share my work - is there a common way for people to share code like this?
Erm... anyone? This sounds worthwhile. Welcome on board! Kas.