Ah, yes ye olde ref count bug. :)
On Thu, Feb 23, 2012 at 4:12 PM, Kassen
On Thu, Feb 23, 2012 at 03:59:40PM -0500, mike clemow wrote:
Alternatively, you can implement this will the append operator:
I have been really enjoying that form lately (in Scheme, but the principle is the same).
I noticed you've been using fluxus a lot the last couple of years. Lisp/Scheme is a really interesting language. I've been trying to code Chuck in as terse and elegant a manner as possible lately. I'm working on some examples that make use of some interesting Chuck easter eggs and feel that I'm bound to run into that ref count bug again. With regard to array assignment, I've been getting a lot of mileage out of using multiline statements to create arrays using the append notation. SomeObject objs[0]; objs << iReturnSomeObject(param1, param2) << iReturnSomeObject(param3, param4) << iReturnSomeObject(param5, param6) << iReturnSomeObject(param7, param8); // iterate over objs... They're great for stacks too. "<<" is like "push" and although the popBack() method just removes the last element, you can implement a proper pop() function like this. fun SomeObject pop(SomeObject objs[]) { objs[objs.size()-1] @=> SomeObject so; objs.popBack(); return so; } (This will likely get you in trouble with that ref count bug if you use it for objects. For primitives, it should work just fine.) Perhaps we can write a Scheme interpreter in Chuck? ;) -Mike
This is very nice when we have a function that is to transform a musical theme. WIth this way (and not with the straight indez-based loop) we can replace a single note with two new ones or remove it, based on some condition. I like that.
Kas. _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users