[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/4] Work towards a more complete implementation of `(rnrs io
From: |
Andreas Rottmann |
Subject: |
Re: [PATCH 3/4] Work towards a more complete implementation of `(rnrs io ports)' |
Date: |
Wed, 24 Nov 2010 00:44:54 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
address@hidden (Ludovic Courtès) writes:
> Hi Andreas,
>
> Looks good, but...
>
> Andreas Rottmann <address@hidden> writes:
>
>> (call-with-port): Don't use `dynamic-wind', as it is against its
>> specification in R6RS 8.2.6.
>
> [...]
>
>> (define (call-with-port port proc)
>> "Call @var{proc}, passing it @var{port} and closing @var{port} upon exit
>> of
>> @var{proc}. Return the return values of @var{proc}."
>> - (dynamic-wind
>> - (lambda ()
>> - #t)
>> - (lambda ()
>> - (proc port))
>> - (lambda ()
>> - (close-port port))))
>> + (call-with-values
>> + (lambda () (proc port))
>> + (lambda vals
>> + (close-port port)
>> + (apply values vals))))
>
> I don’t see what in §8.2.6 would be against ‘dynamic-wind’,
>
To quote that paragraph about `call-with-port':
,----
| Proc must accept one argument. The call-with-port procedure calls proc
| with port as an argument. If proc returns, port is closed automatically
| and the values returned by proc are returned. If proc does not return,
| port is not closed automatically, except perhaps when it is possible to
| prove that port will never again be used for an input or output
| operation.
`----
I interpreted that the way I did based on the question of what should
happen when `proc' throws an exception (or otherwise invokes a
continuation that makes it leave its current dynamic extent). To me, it
seems that in this case, `proc' does not _return_, and hence the port
should not be closed. Just to clarify, by a procedure "returning", I
understand delivering a value (or values) to its continuation, which
does not happen if the procedure invokes some arbitrary (other)
continuation.
FWIW, `call-with-port' is implemented without `dynamic-wind' in Ikarus,
Ypsilon and Larceny.
> and <http://www.r6rs.org/formal-comments/comment-197.txt> seems to
> suggest that it’s OK.
>
Hmm, to me, the answer given to that comment does not really indicate
whether the proposed implementation using `dynamic-wind' is acceptable
or not (which is unfortunate).
Regards, Rotty
--
Andreas Rottmann -- <http://rotty.yi.org/>
- Re: [PATCH 2/4] Add implementation of "transcoded ports", (continued)
- Re: [PATCH 2/4] Add implementation of "transcoded ports", Ludovic Courtès, 2010/11/20
- Re: [PATCH 2/4] Add implementation of "transcoded ports", Andreas Rottmann, 2010/11/21
- [PATCH 1/4] Turn `(rnrs io ports)' into an R6RS library, Andreas Rottmann, 2010/11/21
- [PATCH 2/4] Reorganize the R6RS I/O condition types, Andreas Rottmann, 2010/11/21
- [PATCH 4/4] Add implementation of "transcoded ports", Andreas Rottmann, 2010/11/21
- Re: [PATCH 4/4] Add implementation of "transcoded ports", Ludovic Courtès, 2010/11/24
- Re: [PATCH 4/4] Add implementation of "transcoded ports", Andreas Rottmann, 2010/11/24
- Re: [PATCH 4/4] Add implementation of "transcoded ports", Ludovic Courtès, 2010/11/25
- [PATCH 3/4] Work towards a more complete implementation of `(rnrs io ports)', Andreas Rottmann, 2010/11/21
- Re: [PATCH 3/4] Work towards a more complete implementation of `(rnrs io ports)', Ludovic Courtès, 2010/11/23
- Re: [PATCH 3/4] Work towards a more complete implementation of `(rnrs io ports)',
Andreas Rottmann <=
- Re: [PATCH 3/4] Work towards a more complete implementation of `(rnrs io ports)', Ludovic Courtès, 2010/11/24
[PATCH 1/4] Fix missing port-table locking and bytevector output port segfault, Andreas Rottmann, 2010/11/20
[PATCH 3/4] Reorganize the R6RS I/O condition types, Andreas Rottmann, 2010/11/20
[PATCH 4/4] Work towards a more complete implementation of `(rnrs io ports)', Andreas Rottmann, 2010/11/20