I’ve got a couple small but interesting quark updates. I’ll post them as I can clean them up, but the first is a small but useful 1.0.4 to the Require.quark
has more granular caching, and an easier way to require multiple files.
Formerly, files evaluated by Require
were only evaluated once per code execution (e.g. hitting Cmd+Enter), and would otherwise be cached. This is required so that, in a tree of files requiring each other, a file is only executed once even if 5 other files Require
it. I’ve added more specific cache keys - \serverBoot, \serverTree, \cmdPeriod, \content, \evaluate, \never
- that can be specified to control whena. specific file needs to be re-evaluated.
For example, suppose you have a file that set up some buffers: these will be destroyed when the server is rebooted, so you’ll want to re-execute this ONLY after a server boot. You can specify this by calling Require.cache(\serverBoot)
anywhere in your file:
( // buffers.scd
Require.cache(\serverBoot);
(
bufferA: Buffer.read(...),
bufferB: Buffer.read(...),
bufferC: Buffer.read(...),
)
)
// elsewhere....
Require.with("buffers") {
|buffers|
buffers.bufferA.play;
}
The latter will only be executed ONCE and cached thereafter - but the cache is reset if the server is rebooted. Note that it does not automatically re-evaluate your file, it only allows it to be re-evaluated if you run code that requires it.
The second feature is a better way of requiring multiple files, using the with
method:
Require.with("fileA", "fileB") {
|a, b|
a.postln; b.postln;
}
This is equivalent to doing e.g. var a = Require("fileA")
, though the syntax is a bit more clear. I’m working toward allowing require to be async (if they contain e.g. lots of buffer loading) - in the long run, these requires would happen in parallel, which should improve the speed of loading complex projects. But, for now, theyre synchronous for various reasons related to complexity 