[chuck-users] functions returning arrays

David Ogborn ogbornd at mcmaster.ca
Thu Feb 23 15:59:51 EST 2012


Hi Kas and Colin,

Thanks for your help!  When I properly initialized the array (local to the function, at least at first) it works - without any need for bumping up the reference count.

Yours truly,
David

On 2012-02-23, at 3:45 PM, Kassen wrote:

> On Thu, Feb 23, 2012 at 12:27:22PM -0800, Colin Sullivan wrote:
>> David,
>> 
>> I think the problem may be that you are returning an array that is local to
>> your function and it is getting deallocated when the function returns.
> 
> That's what I thought too, and that certainly can happen.
> In that case a extra assignment (using @) can increase the reference
> count, tricking the simple CC. That's not "good form" just a
> workaround while some of that stuff is a bit dodgy.
> 
> That's not the issue here though, at least not the primary one. The
> primary issue here is that rr gets defined without a length and so
> apparently doesn't get initiated. Editing the relevant line to read;
> 
> float rr[nn.size()];
> 
> makes sure all floats are initiated and for my tests it works.
> 
> I think the issue is not with returning, the reported error is
> refering -I suspect- to the moment when we try to chuck the result of
> the addition to the array location, the error just isn't indicating
> that, obfuscating what went wrong.
> 
> I hope that helps (I also hope it's correct ;-) )
> 
> Yours,
> Kas.
> 
> 
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

-------------------------------------------------------------------
Dr. David Ogborn, Assistant Professor
Communication Studies & Multimedia
Director, Cybernetic Orchestra & ESP Studio
McMaster University, Hamilton, Canada

ogbornd --at-- mcmaster.ca
http://davidogborn.net
http://twitter.com/ogbornd
http://esp.mcmaster.ca (Cybernetic Orchestra)
1-905-525-9140 ext 27603






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20120223/a9e24b83/attachment.html>


More information about the chuck-users mailing list