Rob;<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">FEATURE REQUEST<br>
<br>
As written, array's popBack() function has a void return. It would be nice if popBack() returned the element it removed, so we could write the code like this:<br>
</blockquote><div><br>I agree with this, it's not clear to me why it doesn't do this already. Actually I thought it did but only worked correctly for primitives. I just tested and that turns out to be a mistake.<br>
<br>I think it's clear that we need this and I hope it'll be addressed one when somebody goes over the series of bugs related to arrays and type; it can't be very hard, assuming the other existing issues will be addressed. Our arrays need some loving care.<br>
<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
BUG REPORT<br>
<br>
This may be operator error rather than a bug, but the following code:<br>
<br>
fun Element allocateElement() {<br>
if ((_pool.size() => int size) > 0) {<br>
_pool[size-1] @=> Element @ element;<br>
size-1 => _pool.size;<br>
return element;<br>
}<br>
return new Element;<br>
}<br>
<br>
reports:<br>
<br>
chuck(20184,0xa018a830) malloc: *** error for object 0x5eb6e0: double free<br>
*** set a breakpoint in malloc_error_break to debug<br>
<br>
I think the problem may be in "return new Element" -- it may be trying to return the Element itself, rather than a reference to the Element. If that's the case, though, it seems like something that should be caught at compile time.<br>
</blockquote><div><br>I suspect this is another case of the bits of the GC that are are already in there and occasionally collect things before they need to be collected. Until there is a new version I'm inclined to categorise anything related to more advanced operations on arrays involving no-primitive types on the "Clemow's bane" pile. First of all there is the issue that I think we are seeing here which involves the over-collection of things that aren't (yet) garbage, secondly there is the issue that if you do manage to get a item out of a array in a way like this ChucK will somehow lose track of what type it is at which point there will be issues of a extremely headache-inducing nature.<br>
<br>Mike may be able to help you; I seem to remember him&me got something quite similar to this to work for some of his code but I forgot the details. The one thing my memory hasn't repressed is that the solution involved sprinkling the code with magical "@" signs, more or less at random :¬). I love ChucK but here be dragons.<br>
</div></div><br>Yours,<br>Kas.<br>