[chuck-dev] mini ChucK bug

Tom Lieber lieber at princeton.edu
Sat May 2 17:23:38 EDT 2009


On Sat, May 2, 2009 at 5:05 PM, mike clemow <gelfmuse at gmail.com> wrote:
> I wonder if it's related to the memory address:
>
> fun int almostrandom() {
>    int a => int b;
>    return b;
> }
>
> while(true)
> {
>    <<< almostrandom() >>>;
>    100::ms  => now;
> }
>
> always prints the same number...
>
> while(true)
> {
>    almostrandom() => int d;
>    <<< d >>>;
>    100::ms  => now;
> }
>
> does also...
>
> does "int a" return a memory address or something?

I don't know what's going on inside ChucK, but it does look like the
uninitialized values for integers are memory addresses, maybe pointers
onto the stack? They do grow as I'd expect for that hypothesis...

fun int almostrandom() {
    int a => int b;
    return b;
}

fun void recurse(int times) {
    <<< almostrandom() >>>;
    if(times > 0)
        recurse(times - 1);
}

recurse(10);

Ooh, ooh, points for anyone who uses this bug to implement resource
pooling by memory usage!

-- 
Tom Lieber
http://AllTom.com/


More information about the chuck-dev mailing list