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

Stefan Blixt stefan.blixt at gmail.com
Wed Sep 10 16:29:28 EDT 2008


Yeah, 4 => static int i; in a class should either result in a syntax error
or in 4 being assigned to i once, either at define time or the first time
the class is referenced. The current behaviour is wrong.
/Stefan

On Wed, Sep 10, 2008 at 8:00 PM, Kassen <signal.automatique at gmail.com>wrote:

> Stefan Blixt;
>
>> 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.
>>
>
> Yes. I do suppose this bug/feature could be a side effect of a desire to
> avoid having new instances reset the values of static members... but then
> again those static members don't belong to instances at all and instead
> belong to the class itself.
>
> I could also imagine that the desired functionality might be to have "3 =>
> static int foo;" only run when the class is defined and not when it's
> instantiated. Actually that would make sense to me. At any rate I object to
> the above being functionally identical to "static int foo;" with no warning.
>
> It's interesting to note that ChucK does try;
> This;
> ----------------
> class foo
>     {
>     4.3 => static int bar;
>     }
> ---------------
> Does give a error about being unable to resolve the ChucK operator on types
> float and int.
>
> Kas.
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
>


-- 
Release me, insect, or I will destroy the Cosmos!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20080910/176cd3d4/attachment.htm>


More information about the chuck-users mailing list