On 4/24/07, Daniel Berger <djberg96 / gmail.com> wrote:
> Hi all,
>
> Just curious - why was Ruby's temporary file handling class
> (tempfile.rb) written in pure Ruby instead of using the tmpfile()
> function? That function appears to be supported on most platforms,
> including MS Windows.
>
> Are there file locking or threading issues I'm not aware of?
>
> The tmpfile() function does have the advantage of deleting itself when
> all references to it are gone, instead of waiting until the Ruby
> process itself dies. Perhaps there's no real advantage to that,
> though?
>

The Ruby Tempfile class creates a finalizer that will delete the temp
file when it is collected by the garbage collector; the Ruby Tempfile
also deletes the temp file when it is closed. Your paragraph above
makes it sound like this is not the case.

> Like I said, not an issue, just curious.

I do not know why the C tmpfile function was not used. Maybe Matz
likes programming in Ruby more than programming in C   ;)

Blessings,
TwP