New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
finalisation + constants #2977
Comments
Comment author: administrator Hi Markus,
That's what the doc means when it says "implementation-dependent". Byte-code
Things like finalisation and weak pointers do expose some details of the The other reason is that we don't want to paint ourselves in a corner by I'm adding a sentence in gc.mli to say that the results of String.make, -- Damien |
Comment author: administrator On Fri, 05 Oct 2001, Damien Doligez wrote:
Ok, I see. I thought behaviour was merely "unspecified" like evaluation
Understandable. It might be interesting to know what kind of optimisations Regards, -- |
Original bug ID: 555
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Hello,
although it is documented that finalisation does not work on constants,
there is somewhat inconsistent behaviour here between native code and
byte code, e.g.:
let rec loop () = Gc.full_major (); loop ()
let finaliser _ = print_endline "FINALISER!"; flush stdout
let _ = Gc.finalise finaliser [()]; loop ()
When called as byte code, nothing happens (finaliser isn't called). When
compiling to native code, the program bails out with an exception:
Fatal error: uncaught exception Invalid_argument("Gc.finalise")
I assume this is a consequence of the two compilers treating constants
slightly differently. Now we use the following line instead of the
last one:
let _ = Gc.finalise finaliser []; loop ()
This time the program will raise an exception in both cases as expected
considering the docs.
Now we write this instead:
let _ = let u = () in Gc.finalise finaliser [u]; loop ()
This will trigger the finaliser in both cases so constants are obviously
not substituted at compile time, which could be surprising to people in
such simple cases.
Regards,
Markus
--
Markus Mottl markus@oefai.at
Austrian Research Institute
for Artificial Intelligence http://www.oefai.at/~markus
The text was updated successfully, but these errors were encountered: