[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Scheme-reports] valid implementation of call-with-input-file?
- To: scheme-reports <scheme-reports@x>
 
- Subject: [Scheme-reports] valid implementation of call-with-input-file?
 
- From: Andy Wingo <wingo@x>
 
- Date: Sun, 19 Aug 2012 11:23:03 +0200
 
Hello,
Is this implementation of call-with-input-file valid?
  (define (call-with-input-file filename proc)
    (let ((port (open-input-file filename)))
      (with-exception-handler
        (lambda (x)
          (close-input-port port)
          x)
        (lambda ()
          (call-with-values (lambda () (proc port))
            (lambda vals
              (close-input-port port)
              (apply values vals)))))))
I think no, due to the language on p52 of the report:
    If proc does not return, then the
    port must not be closed automatically unless it is possible
    to prove that the port will never again be used for a read
    or write operation.
I think we should specify that exceptional exits close the port, as the
above implementation does.
Andy
-- 
http://wingolog.org/
_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports