[chuck-users] functions returning arrays

mike clemow michaelclemow at gmail.com
Thu Feb 23 16:29:35 EST 2012

Ah, yes ye olde ref count bug.  :)

On Thu, Feb 23, 2012 at 4:12 PM, Kassen <signal.automatique at gmail.com> wrote:
> 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

With regard to array assignment, I've been getting a lot of mileage
out of using multiline statements to create arrays using the append

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;
    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?  ;)


> 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 at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

More information about the chuck-users mailing list