spencersalazar / chuck

28 stars 8 forks source link

Static dur field not static #40

Open heuermh opened 10 years ago

heuermh commented 10 years ago

I believe this may already be a known issue; it appears static dur fields are not statically initialized

class Impatient
{
  1::ms => static dur moment;

 fun static void pause()
 {
    <<<"just a moment...", moment>>>;
  }
}

Impatient.pause();

reports

$ chuck impatient.ck 
just a moment... 0.000000

instead of the desired

$ chuck impatient.ck 
just a moment... 44.100000

See also

https://github.com/heuermh/lick/blob/master/Loops.ck#L26

spencersalazar commented 10 years ago

Right -- the usual workaround is to initialize in the code following the class declaration. E.g.

class Impatient
{
  static dur moment;

  fun static void pause()
  {
    <<<"just a moment...", moment>>>;
  }
}

1::ms => Impatient.moment;

Impatient.pause();

But a legitimate fix would be ideal.