[chuck-users] Assigning to appended array locations (bug?)

Stephen Sinclair radarsat1 at gmail.com
Sun Sep 28 16:55:39 EDT 2008


On Sun, Sep 28, 2008 at 4:39 PM, Kassen <signal.automatique at gmail.com> wrote:
>>  Must mean it's a garbage
>> collection issue, since in this case there remains in memory a
>> reference to the new Foo.
>
> I'm not surprised about that at all considering the error message talks
> about a reference count and Ge has mentioned using those for garbage
> collection.
>
> Great, so now we do have at least some garbage collection, even if it's not
> working perfectly yet. That's at least a silver lining.

Yup, it probably needs some work, and at least I think reference-based
garbage collection is a little easier to get right than the "hunt
through memory for pointers" style.  Though each has its own downsides
if I recall, such as cyclical references.


>>  If you add "baz @=> f;" to the end of this
>> script, it crashed, which proves it.
>
> Ok.... but I'd say that line should be valid as there *is* a rather clear
> reference to "f". This is kept track of as well because appending the file
> with "int f;" instead will give a (correct) complaint about "f" already
> having been defined in this scope. I can understand there being some bug
> left in the initialisation of apended array locations as those are new but
> calling a instance "f" is not new at all. It seems like there is something
> going wrong with the reference count in assignment as well or instead.

Well, I'm not sure if I understand what you're saying, but what's
happening is that 'f' references a new Foo, and then that foo is added
to the array.  When it's later replaced, it's not garbage collected
because 'f' still references it.  But when 'f' is made to point
somewhere else, *then* it gets garbage collected, which for some
reason causes an exception.

Appended 'int f' doesn't make much sense though since the problem
doesn't lie with 'f', but with what 'f' points to.  It'll just say
that 'f' is already defined.


>> new Foo @=> Foo @f;
>> foo << f;
>
> Lovely. I'll take this to Mike's "spaghetti  with spicy bug-sauce" and see
> how far that gets us.
>
> It's kinda ironical how civilisation has gotten us to the point where we can
> debate programing languages internationally over a electronic network yet we
> are still forced to organise hunting parties. Nice catch you got there.

Ha. :)


Steve


More information about the chuck-users mailing list