Is there a way to explicitly destroy object references?
Currently, ChucK is undergoing much development in terms of garbage collection. In the released version, objects are ref counted, but not all references are released correctly yet. This means either structuring code to minimize garbage, or "manually" releasing references, in order to control memory usage for now. Someday soonish, ChucK is going to be a (hopefully properly) garbage collected language, which means the programmer will not have to manually release objects after use.
For instance, in a loop, I am creating an array of objects like so:
Object objects[4]; 0 => int count;
for(0 => int i; i < 4; i++ ) { new Object @=> objects[count]; count++; }
Now how would I delete the Object referenced at, say, objects[0]?
In this particular case, by assigning new instances of Object into objects[0], the old objects should have been released automatically. You can also assign 'null' to object references to decrement their ref counts, and if no other references exist to that object, it will be released. Also, as you probably know, one can declare arrays of null references, to reduce redundant/useless instantiations: // array of null Object references Object @ objects[4]; We are still experimenting with various options for garbage collecting ChucK, and will likely adopt two or three approaches for initial release/testing, selectable by the programmer. In any case, we don't expect any syntax-alterations to the language. We will continue to keep you posted. Thanks! Best, Ge!