<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1476" name=GENERATOR>
<STYLE></STYLE>
</HEAD><FONT face=Arial><FONT size=2>
<BODY>
<DIV>Problem: Chuck language definition uses cap(), when it should use 
size().</DIV>
<DIV>&nbsp;</DIV>
<DIV>An example from the Chuck language specficiation:<BR><BR><A 
href="http://chuck.cs.princeton.edu/doc/language/array.html">http://chuck.cs.princeton.edu/doc/language/array.html</A><BR><BR>&nbsp;&nbsp; 
// print it<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for( 0 =&gt; int i; i 
&lt; bar.cap(); i++ 
)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;&lt;&lt; bar[0] &gt;&gt;&gt;;<BR>&nbsp;&nbsp;&nbsp; }<BR><BR>From 
chuck_lang.cpp<BR>// array.cap()<BR>CK_DLL_MFUN( array_capacity 
)<BR>{<BR>&nbsp;&nbsp;&nbsp; Chuck_Array * array = (Chuck_Array 
*)SELF;<BR>&nbsp;&nbsp;&nbsp; RETURN-&gt;v_int = 
array-&gt;capacity();<BR>}<BR><BR>From STL 
docs:<BR><BR>std::vector&lt;xx&gt;::capacity()<BR>&nbsp;&nbsp;&nbsp;&nbsp; The 
member function returns the storage currently allocated to hold 
the<BR>controlled sequence, a value at least as large as size<BR><BR>One of 
these is wrong (probably not the STL docs. ;--) ). Either bar.size(),<BR>or 
array-&gt;size() would do it.<BR><BR>std::vector&lt;&gt;::capacity() is not the 
same thing as std::vector&lt;&gt;::size().<BR>It's common practice (if not a 
standards requirement) for STL<BR>implementations to grow arrays by doubling 
capacity() as the size()<BR>increases, instead of growing capactity() by one 
each time, becuase this<BR>provides O(1) performance for push_back instead of 
O(2) performance.<BR></DIV>
<DIV><BR>Which brings me to my next feature request.... &lt;grin&gt;<BR><BR>I 
don't suppose the Array push_back/pop-back/&amp;c methods could 
be<BR>re-instituted? It's nice to have dynamic arrays; but, in the 
current<BR>implementation, there's no way to grow the integer-indexed portion 
of<BR>arrays.<BR><BR>A use case:<BR><BR>I'm writing VoiceManager, a 
voice-manager class, that implements polyphonic<BR>playing on classes that 
implement IInstrument. One of the parameters to<BR>VoiceManager is how many 
instances of the instrument to create. The problem:<BR>how to declar an array to 
hold the instruments?<BR><BR>&nbsp;&nbsp;&nbsp; IInstrument 
instruments[];<BR>Doesn't create an array.<BR>&nbsp;&nbsp;&nbsp; [] @=&gt; 
IInstrument instruments[];<BR>is gramattically illegal.<BR>&nbsp;&nbsp;&nbsp; 
IInstrument instruments[0];<BR>isn't growable.<BR>&nbsp;&nbsp;&nbsp; <BR>The 
ideal solution:<BR>&nbsp;&nbsp;&nbsp; IInstrument 
instruments[];<BR>....<BR>&nbsp;&nbsp;&nbsp; 
instruments.push_back(instr);<BR><BR>Tantalizing, because array_push_back is 
present in the sources, but doesn't<BR>seem to be implemented in the 
language.<BR><BR>Priority of the feature request: nice to have, but not 
absolutely required.<BR>static members would be my first choice. I used 
IInstrument<BR>instruments[256]; to work around the problem.<BR><BR>Best 
Regards,<BR><BR>Robin Davies.<BR></DIV></BODY></HTML></FONT></FONT>