Oz and Mozart Users Mailing List

Re: _Extremely_ strange behaviour. Help!


From: Christian Schulte (schulte@ps.uni-sb.de)
Date: Tue Aug 28 2001 - 10:08:03 CEST


Robin,

This time you have a hit, but there is workaround ;-) You will see an entry
E on the finalization stream, as soon as there is a proof by the system that
there is no computation that can refer to E, that is, E is dead. The proof
is done by the garbage collector.

Unfortunately, compilation in the interactive system (aka on toplevel) tends
to keep references even to local variables. I am no expert on this, but
maybe Leif can elaborate on this issue.

Now, if you wrap your stuff into a procedure declaration it works as
expected. So check this out:

declare
fun {Stranger}
   Weak L
in
   {WeakDictionary.new L Weak}
   local
      proc {Foo X}
          skip
      end
   in
      {WeakDictionary.put Weak 'Bar' Foo}
      {Foo 'Baz'}
   end
   L
end

{Inspect {Stranger}}
{System.gcDo}

This shows the desired effect.

Amazingly, taking your original example works as soon as you re-declare Foo
on toplevel...

Cheers
Christian

----- Original Message -----
From: "Robin Lee Powell" <rlpowell@digitalkingdom.org>
Newsgroups: mozart-oz.users
Sent: Monday, August 27, 2001 7:21 PM
Subject: Re: _Extremely_ strange behaviour. Help!

> On Mon, Aug 27, 2001 at 10:48:14AM +0200, Christian Schulte wrote:
> > Sorry, but I have to admit that I don't get your point. Could you maybe
> > extract the full program needed, describe how to run it, describe the
output
> > you expect and describe the output you get. Maybe we can help then.
>
> Understandable. 8)
>
> Fortunately I have managed to get it down to a much simpler problem.
>
> Here's a pseudo-code fragment:
>
> ...
>
> {WeakDictionary.new L Weak}
> local Foo in
> Foo = proc ... end
> {WeakDictionary.put Weak 'Bar' Foo}
> {Foo 'Baz'}
> end
>
> {System.gcDo}
>
> ...
>
>
> As it stands, Foo is not sent to the finalization stream at the gcDo
> call.
>
> If I comment out the {Foo 'Baz'} call, it is.
>
> This seems like bad behaviour.
>
> -Robin
> -
> Please send submissions to users@mozart-oz.org
> and administriva mail to users-request@mozart-oz.org.
> The Mozart Oz web site is at http://www.mozart-oz.org/.

-
Please send submissions to users@mozart-oz.org
and administriva mail to users-request@mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.



This archive was generated by hypermail 2b29.