guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: request tmpfile(3) wrapping in Guile 1.9 libguile


From: Andy Wingo
Subject: Re: request tmpfile(3) wrapping in Guile 1.9 libguile
Date: Mon, 08 Feb 2010 12:11:17 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux)

Hi Thien-Thi,

On Sun 07 Feb 2010 19:48, Thien-Thi Nguyen <address@hidden> writes:

> I'm writing to request that tmpfile(3) be added to Guile 1.9 libguile.

I think this sounds like a good idea. I have a few concerns, though if
none of them can be nicely addressed I'd still be happy adding tmpfile.

1. tmpfile(3) returns a FILE*, whereas Guile's fports normally deal in
file descriptors. Will this be a problem? What about buffering? Do we
have to fclose() the FILE* to get deletion working?

2. Why return 'tmpfile as the name, and not whatever filename one can
get from the FILE* ?

3. Is tmpfile(3) really needed, if you have mkstemp! and dynamic
extents? Here's what I use, for example:

(define-macro (unwind-protect form . cleanups)
  `(dynamic-wind (lambda () #t)
       (lambda () ,form)
       (lambda () ,@cleanups)))

(define (call-with-temp-file contents proc)
  (let* ((template (string-copy "/tmp/tekutiXXXXXX"))
         (tmp (mkstemp! template)))
    (display contents tmp)
    (close tmp)
    (unwind-protect
     (proc template)
     (delete-file template))))

Granted, one has to consider what to do on rewind... Regarding that, I
enjoyed Taylor Campbell's entry from
http://mumble.net/~campbell/blag.txt about unwind-protect.

Anyway, I digress. Anyone have thoughts about these?

Andy
-- 
http://wingolog.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]