[racket] Destructors in Racket

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Aug 2 06:57:32 EDT 2014

No, use the safe "will executors" API, instead.

The unsafe finalizer API is for low-level, atomic finalization. Closing a port can flush buffers and more, and it's not a good idea to do that in an unsafe atomic context.

> On Aug 2, 2014, at 11:12 AM, Roman Klochkov <kalimehtar at mail.ru> wrote:
> I have a structure, that has a filestream inside it. File have to be cosed, when the structure is not used anymore (so gargbage collected).
> Is the best way to do
> (require ffi/unsafe)
> (register-finalizer my-obj
>    (lambda (x) (close-output-port (obj-file x))))
> ?
> It seems doing right thing, but why `ffi/unsafe'? Is it OK, when my program actually doesn't use FFI?
> -- 
> Roman Klochkov
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

Posted on the users mailing list.