* [Caml-list] One more question about Gc.finalise
@ 2017-06-18 23:45 Evgeny Roubinchtein
2017-06-19 6:02 ` François Bobot
0 siblings, 1 reply; 3+ messages in thread
From: Evgeny Roubinchtein @ 2017-06-18 23:45 UTC (permalink / raw)
To: OCaml Mailing List
[-- Attachment #1: Type: text/plain, Size: 538 bytes --]
Dear OCaml users and developers,
I have one more question about Gc.finalise to which I couldn't find an
answer in the documentation.
Suppose I do, "Gc.finalise f v", and the function f makes the value v
reachable again. If I want f to be called again should v become
unreachable again, do I need to again call "Gc.finalise f v", after f has
"revived" v?
My experimentation _seems_ to suggest that I do, but there is always the
danger that I am misinterpreting the results of my experiment. :-)
Thank you in advance!
--
Best,
Zhenya
[-- Attachment #2: Type: text/html, Size: 701 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] One more question about Gc.finalise
2017-06-18 23:45 [Caml-list] One more question about Gc.finalise Evgeny Roubinchtein
@ 2017-06-19 6:02 ` François Bobot
2017-06-19 12:04 ` Jacques-Henri Jourdan
0 siblings, 1 reply; 3+ messages in thread
From: François Bobot @ 2017-06-19 6:02 UTC (permalink / raw)
To: caml-list
Hi,
Le 19/06/2017 à 01:45, Evgeny Roubinchtein a écrit :
> I have one more question about Gc.finalise to which I couldn't find an answer in the documentation.
> Suppose I do, "Gc.finalise f v", and the function f makes the value v reachable again. If I want f
> to be called again should v become unreachable again, do I need to again call "Gc.finalise f v",
> after f has "revived" v?
I think so, but I didn't double checked with the code.
>
> My experimentation _seems_ to suggest that I do, but there is always the danger that I am
> misinterpreting the results of my experiment. :-)
With newer ocaml version (>= 4.04), you can use `GC.finalise_last` which can't use the value
finalised (unit instead of 'a is given to the function `f`) but the function `f` will really be
called after `v` is unreachable for the last time, just before being reclaimed. Perhaps it could fit
better what you have in mind.
Best,
--
François
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] One more question about Gc.finalise
2017-06-19 6:02 ` François Bobot
@ 2017-06-19 12:04 ` Jacques-Henri Jourdan
0 siblings, 0 replies; 3+ messages in thread
From: Jacques-Henri Jourdan @ 2017-06-19 12:04 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 655 bytes --]
On 06/19/2017 08:02 AM, François Bobot wrote:
> Hi,
>
> Le 19/06/2017 à 01:45, Evgeny Roubinchtein a écrit :
>> I have one more question about Gc.finalise to which I couldn't find
>> an answer in the documentation.
>> Suppose I do, "Gc.finalise f v", and the function f makes the value v
>> reachable again. If I want f
>> to be called again should v become unreachable again, do I need to
>> again call "Gc.finalise f v",
>> after f has "revived" v?
>
>
> I think so, but I didn't double checked with the code.
Indeed it is. This is even used to implement alarm in stdlib :
https://github.com/ocaml/ocaml/blob/trunk/stdlib/gc.ml#L103
--
JH
[-- Attachment #2: Type: text/html, Size: 1363 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-19 12:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-18 23:45 [Caml-list] One more question about Gc.finalise Evgeny Roubinchtein
2017-06-19 6:02 ` François Bobot
2017-06-19 12:04 ` Jacques-Henri Jourdan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox