<div>Hey Kassen,</div><div><br></div>Thanks for looking into it.  I'm picking up what you're putting down, pretty much.  int ar[] is a reference to nothing, like a null pointer, so asking the VM to call a method is accessing uninitialized memory, like a seg fault.  I think I shouldn't have said "crashes" when what I meant was, the thread dies and throws an exception, not that the audicle executable nor the VM breaks.  It's a run-time error and not a syntax error; that's what I had in mind.<br>
<br>I am glad to understand ChucK a little better.<div><br></div><div>Thanks again,</div><div>George<br><br><div class="gmail_quote">On Sat, Jul 28, 2012 at 9:42 AM, Kassen <span dir="ltr"><<a href="mailto:signal.automatique@gmail.com" target="_blank">signal.automatique@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> Hi,<br>
<br>
Hey George!<br>
<div class="im"><br>
><br>
> array.size(int) and the '<<' operator are crashing miniAudicle (version<br>
> 0.2.0, on Windows 7 pro).  (functionality added to chuck in 1.2.1.2,<br>
> <a href="http://chuck.cs.princeton.edu/release/VERSIONS" target="_blank">http://chuck.cs.princeton.edu/release/VERSIONS</a> ).  miniAudicle tells me it's<br>
> running chuck 1.2.1.2.<br>
<br>
</div>Check.<br>
<div class="im"><br>
<br>
> playing around a bit, I now find that if I follow what the example<br>
> <a href="http://array_dynamic.ck" target="_blank">array_dynamic.ck</a> says and replace "int ar[]" with "int ar[0]", then the code<br>
> works.  I guess that means this isn't a bug but a meaningful difference<br>
> between ar[] and ar[0]?  In any case, I might amend the <a href="http://array_dynamic.ck" target="_blank">array_dynamic.ck</a> to<br>
> say something like<br>
> "float argh[0]; // must set argh[0] and not argh[]"<br>
><br>
<br>
</div>Well, if ChucK crashes it's a bug; ChucK should not crash if you make<br>
a syntax error, it should catch it at parsing and inform you. It is<br>
also not unambiguously clear to me that what you tried is actually a<br>
error, IMHO this should be fair game, it looks natural and expressive.<br>
I can tell you what goes wrong though.<br>
<br>
"int ar[]" creates a reference to a array but does not instantiate it.<br>
You'd use it in a context like this;<br>
[1, 2, 3] @=> int ar[];<br>
<br>
Evidently ar.size(int a) should instantiate the new array entries if a<br>
is larger than the old size, which it'll always be for uninstantiated<br>
arrays so I find what you tried defensible, but ChucK is also a bit<br>
right to complain about a null-pointer as the reference doesn't point<br>
to anything yet at that point. Syntactically it seems a bit awkward,<br>
compared to the rest of ChucK where we don't need to care about memory<br>
management, though it might also have uses where this kind of explicit<br>
control is useful.<br>
<br>
I hope that clarifies things a bit? If all of this sounded like<br>
abracadabra; just use the one that works, that's what this comes down<br>
to :-)<br>
<br>
Yours,<br>
Kas.<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
</div></div></blockquote></div><br></div>