unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Kevin Ryde <user42@zip.com.au>
Subject: doco ports verbiage
Date: Thu, 12 Jun 2003 10:56:29 +1000	[thread overview]
Message-ID: <877k7sm7uq.fsf@zip.com.au> (raw)

[-- Attachment #1: Type: text/plain, Size: 2509 bytes --]

This is in the interests of reducing duplication.  For with- and
call-with- I found it a bit hard to see quite what was going on with
five rather similar chunks of text.

	* scheme-io.texi (File Ports): Describe call-with-input-file and
	call-with-output-file together.  Describe with-input-from-file,
	with-output-to-file and with-error-to-file together.
	(Closing): Describe close-input-port and close-output-port together,
	tweak the wording slightly.

The words are slightly rearranged in support of this, but what's
specified is not changed.



 - Scheme Procedure: call-with-input-file filename proc
 - Scheme Procedure: call-with-output-file filename proc
     Open FILENAME for input or output, and call `(PROC port)' with the
     resulting port.  Return the value returned by PROC.

     For input, FILENAME must exist.  For output, if FILENAME already
     exists the behaviour is unspecified.  In both cases if FILENAME
     cannot be opened an error is signalled.

     When PROC returns, the port is closed.  If PROC does not return
     (eg. if it throws an error), then the port might not be closed
     automatically, though it will be garbage collected in the usual
     way if not otherwise referenced.

 - Scheme Procedure: with-input-from-file filename thunk
 - Scheme Procedure: with-output-to-file filename thunk
 - Scheme Procedure: with-error-to-file filename thunk
     Open FILENAME and call `(THUNK)' with the port setup as
     respectively the `current-input-port', `current-output-port', or
     `current-error-port'.  Return the value returned by THUNK.

     For input, FILENAME must exist.  For output and error output, if
     FILENAME already exists the behaviour is unspecified.  In all
     cases if FILENAME cannot be opened, an error is signalled.

     When THUNK returns, the port is closed and the previous setting of
     the respective current port is restored.  If THUNK does not return
     (eg. if it throws an error), then what happens to the ports is
     unspecified.




 - Scheme Procedure: close-input-port port
 - Scheme Procedure: close-output-port port
 - C Function: scm_close_input_port (port)
 - C Function: scm_close_output_port (port)
     Close the specified input or output PORT.  An exception may be
     raised if an error occurs while closing.  If PORT is already
     closed, nothing is done.  The return value is unspecified.

     See also *Note close: Ports and File Descriptors, for a procedure
     which can close file descriptors.




[-- Attachment #2: scheme-io.texi.ports.diff --]
[-- Type: text/plain, Size: 6486 bytes --]

--- scheme-io.texi.~1.12.~	2003-06-01 10:18:51.000000000 +1000
+++ scheme-io.texi	2003-06-12 10:45:48.000000000 +1000
@@ -301,23 +301,15 @@
 descriptors.
 @end deffn
 
-@rnindex close-input-port
 @deffn {Scheme Procedure} close-input-port port
+@deffnx {Scheme Procedure} close-output-port port
 @deffnx {C Function} scm_close_input_port (port)
-Close the specified input port object.  The routine has no effect if
-the file has already been closed.  An exception may be raised if an
-error occurs.  The value returned is unspecified.
-
-See also @ref{Ports and File Descriptors, close}, for a procedure
-which can close file descriptors.
-@end deffn
-
-@rnindex close-output-port
-@deffn {Scheme Procedure} close-output-port port
 @deffnx {C Function} scm_close_output_port (port)
-Close the specified output port object.  The routine has no effect if
-the file has already been closed.  An exception may be raised if an
-error occurs.  The value returned is unspecified.
+@rnindex close-input-port
+@rnindex close-output-port
+Close the specified input or output @var{port}.  An exception may be
+raised if an error occurs while closing.  If @var{port} is already
+closed, nothing is done.  The return value is unspecified.
 
 See also @ref{Ports and File Descriptors, close}, for a procedure
 which can close file descriptors.
@@ -709,68 +701,42 @@
 @end smalllisp
 @end deffn
 
+@deffn {Scheme Procedure} call-with-input-file filename proc
+@deffnx {Scheme Procedure} call-with-output-file filename proc
 @rnindex call-with-input-file
-@deffn {Scheme Procedure} call-with-input-file file proc
-@var{proc} should be a procedure of one argument, and @var{file} should
-be a string naming a file.  The file must already exist. These
-procedures call @var{proc} with one argument: the port obtained by
-opening the named file for input or output.  If the file cannot be
-opened, an error is signalled.  If the procedure returns, then the port
-is closed automatically and the value yielded by the procedure is
-returned.  If the procedure does not return, then the port will not be
-closed automatically unless it is possible to prove that the port will
-never again be used for a read or write operation.
-@end deffn
-
 @rnindex call-with-output-file
-@deffn {Scheme Procedure} call-with-output-file file proc
-@var{proc} should be a procedure of one argument, and @var{file} should
-be a string naming a file.  The behaviour is unspecified if the file
-already exists. These procedures call @var{proc} with one argument: the
-port obtained by opening the named file for input or output.  If the
-file cannot be opened, an error is signalled.  If the procedure returns,
-then the port is closed automatically and the value yielded by the
-procedure is returned.  If the procedure does not return, then the port
-will not be closed automatically unless it is possible to prove that the
-port will never again be used for a read or write operation.
-@end deffn
-
+Open @var{filename} for input or output, and call @code{(@var{proc}
+port)} with the resulting port.  Return the value returned by
+@var{proc}.
+
+For input, @var{filename} must exist.  For output, if @var{filename}
+already exists the behaviour is unspecified.  In both cases if
+@var{filename} cannot be opened an error is signalled.
+
+When @var{proc} returns, the port is closed.  If @var{proc} does not
+return (eg.@: if it throws an error), then the port may not be closed
+automatically, though it will be garbage collected in the usual way if
+not otherwise referenced.
+@end deffn
+
+@deffn {Scheme Procedure} with-input-from-file filename thunk
+@deffnx {Scheme Procedure} with-output-to-file filename thunk
+@deffnx {Scheme Procedure} with-error-to-file filename thunk
 @rnindex with-input-from-file
-@deffn {Scheme Procedure} with-input-from-file file thunk
-@var{thunk} must be a procedure of no arguments, and @var{file} must be
-a string naming a file.  The file must already exist. The file is opened
-for input, an input port connected to it is made the default value
-returned by @code{current-input-port}, and the @var{thunk} is called
-with no arguments.  When the @var{thunk} returns, the port is closed and
-the previous default is restored.  Returns the value yielded by
-@var{thunk}.  If an escape procedure is used to escape from the
-continuation of these procedures, their behavior is implementation
-dependent.
-@end deffn
-
 @rnindex with-output-to-file
-@deffn {Scheme Procedure} with-output-to-file file thunk
-@var{thunk} must be a procedure of no arguments, and @var{file} must be
-a string naming a file.  The effect is unspecified if the file already
-exists.  The file is opened for output, an output port connected to it
-is made the default value returned by @code{current-output-port}, and
-the @var{thunk} is called with no arguments.  When the @var{thunk}
-returns, the port is closed and the previous default is restored.
-Returns the value yielded by @var{thunk}.  If an escape procedure is
-used to escape from the continuation of these procedures, their behavior
-is implementation dependent.
-@end deffn
-
-@deffn {Scheme Procedure} with-error-to-file file thunk
-@var{thunk} must be a procedure of no arguments, and @var{file} must be
-a string naming a file.  The effect is unspecified if the file already
-exists.  The file is opened for output, an output port connected to it
-is made the default value returned by @code{current-error-port}, and the
-@var{thunk} is called with no arguments.  When the @var{thunk} returns,
-the port is closed and the previous default is restored.  Returns the
-value yielded by @var{thunk}.  If an escape procedure is used to escape
-from the continuation of these procedures, their behavior is
-implementation dependent.
+Open @var{filename} and call @code{(@var{thunk})} with the port setup
+as respectively the @code{current-input-port},
+@code{current-output-port}, or @code{current-error-port}.  Return the
+value returned by @var{thunk}.
+
+For input, @var{filename} must exist.  For output and error output, if
+@var{filename} already exists the behaviour is unspecified.  In all
+cases if @var{filename} cannot be opened, an error is signalled.
+
+When @var{thunk} returns, the port is closed and the previous setting
+of the respective current port is restored.  If @var{thunk} does not
+return (eg.@: if it throws an error), then what happens to the ports
+is unspecified.
 @end deffn
 
 @deffn {Scheme Procedure} port-mode port

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

             reply	other threads:[~2003-06-12  0:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-12  0:56 Kevin Ryde [this message]
2003-06-12 14:02 ` doco ports verbiage Marius Vollmer
2003-06-14  0:02   ` Kevin Ryde
2003-06-14  0:32     ` Marius Vollmer
2003-06-15  0:32       ` Kevin Ryde
2003-06-18 23:39         ` Marius Vollmer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877k7sm7uq.fsf@zip.com.au \
    --to=user42@zip.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).