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

call-with-xput-port vs. call-with-xput-file



    Date: Mon, 14 Jul 86 11:47:21 est
    From: Kent Dybvig <dyb%iuvax.indiana.edu@CSNET-RELAY.ARPA>
    To: rrrs-authors%mit-mc.CSNET@CSNET-RELAY.ARPA
    Subject: call-with-xput-port vs. call-with-xput-file
    
    I favor changing call-with-input-file and call-with-output-file to
    call-with-input-port and call-with-output-port.  However, I have some
    questions related to the change and to ports in general.
    
    1.  I saw lots of confusion over the fact that you open a file (with
    open-input-file and open-output-file) but close a port (with close-
    input-port and close-output-port).  Changing the "call-with" names
    could increase the confusion.  Should we change open-input-file and
    open-output-file to open-input-port and open-output-port?
    
    2.  I have added string ports to Chez Scheme and need to choose names.
    If we have call-with-...-file and open-...-file, I can introduce the
    names call-with-...-string and open-...-string.  On the other hand,
    if we have call-with-...-port and open-...-port, I can introduce the
    names call-with-...-string-port and open-...-string-port.  The names
    are longer but perhaps more descriptive.  How do these names sound?
    The point of this question is that any names we choose should
    generalize to other types of ports.

I see these two points (together with general conservatism) as arguments
AGAINST changing the names.  I am now inclined not to make the change.
    
    5.  Why is call-with-input-file essential and open-input-file not?

This resulted from a general spirit of minimalism at the Brandeis
meeting.  The first is sufficient while the second isn't.  Personally, I
never use the second.

    If call-with-input-file is analogous to
    call-with-current-continuation, why do we not have
    (call-with-new-string <length> <proc>) instead of make-string or
    (call-with-pair <obj1> <obj2> <proc>) instead of cons, etc?  Because
    call-with-current-continuation is special---a function
    make-continuation would be problematic.  In short, while I see the
    merit in with-input-from-file since it closes the file and rebinds a
    standard port, I cannot see the merit in call-with-input-file.

The merit is that it makes certain that the port gets closed.  If we had to
deallocate resources and locks associated with allocated objects like strings,
then I think it would be a good idea to have call-with things for
those too.

Jonathan.