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&#39;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&#39;s not clear to me why it doesn&#39;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&#39;s clear that we need this and I hope it&#39;ll be addressed one when somebody goes over the series of bugs related to arrays and type; it can&#39;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() =&gt; int size) &gt; 0) {<br>
                _pool[size-1] @=&gt; Element @ element;<br>
                size-1 =&gt; _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 &quot;return new Element&quot; -- it may be trying to return the Element itself, rather than a reference to the Element.  If that&#39;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&#39;m inclined to categorise anything related to more advanced operations on arrays involving no-primitive types on the &quot;Clemow&#39;s bane&quot; pile. First of all there is the issue that I think we are seeing here which involves the over-collection of things that aren&#39;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&amp;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&#39;t repressed is that the solution involved sprinkling the code with magical &quot;@&quot; signs, more or less at random :¬). I love ChucK but here be dragons.<br>
</div></div><br>Yours,<br>Kas.<br>