[chuck-users] setting static data at construction (bug)
stefan.blixt at gmail.com
Wed Sep 10 13:40:03 EDT 2008
Aha - so the initialization of a static member of a class doesn't work at
all. I see. I am a bit confused about the mixing of static variable
declarations and constructor code in classes - I would think it would be
more clear if the two were separated syntactically somehow. But I guess it
will work this way also.
On Wed, Sep 10, 2008 at 5:55 PM, Kassen <signal.automatique at gmail.com>wrote:
>> 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.
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
Release me, insect, or I will destroy the Cosmos!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the chuck-users