[chuck-users] setting static data at construction (bug)

Kassen signal.automatique at gmail.com
Wed Sep 10 11:55:29 EDT 2008


Stefan;


> After the first has executed daVariable = 9. After the second has executed
> daVariable = 8.
>
> ...?
>

Well, what happens is that the second example works correctly, in the second
case the variable is set to 9, after which instances are created and all of
those instances set the variable to 8 at construction, hence the value is 8.
In the second case the constructor doesn't work (at least not for setting
the value to 9) which is the bug under debate. This means there is nothing
to change the value to something else after it is set and you get a 9 (and
it was a 0 before it was set to 9, not a 8).

When instantiating a class all code in it's body is executed so in the
example that works correctly it's useless to set the variable at that spot
as after that it's reset to 8 (7 times in a row, in fact).

A bit confusing, I admit.

Kas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20080910/5606f580/attachment.htm>


More information about the chuck-users mailing list