guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] GNU Guile branch, master, updated. v2.1.0-155-gf6e6b51


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, master, updated. v2.1.0-155-gf6e6b51
Date: Tue, 06 Mar 2012 00:07:43 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=f6e6b5181aaf068d06709d94e765b9ff5ecb2eaa

The branch, master has been updated
       via  f6e6b5181aaf068d06709d94e765b9ff5ecb2eaa (commit)
       via  124bc316a6831bc842c25769731e92181fd8a711 (commit)
       via  d867c7496ce6caea7f449658306b85db3c95616c (commit)
       via  f7955da9663804812a914b17459483d376db42aa (commit)
       via  f28dc43c959f74164daf9eeabfdd6ccb19556f60 (commit)
       via  0f6f5fb7f83e6faa3547a116cd6b43d947f429b0 (commit)
       via  418321524a3a239326cb96f2dbd03c16cea9b762 (commit)
      from  663c5875f516ae9b36c6100dddd328de4c115147 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f6e6b5181aaf068d06709d94e765b9ff5ecb2eaa
Author: Andy Wingo <address@hidden>
Date:   Tue Mar 6 00:51:31 2012 +0100

    shuffle r4rs procedures into boot-9
    
    * module/ice-9/boot-9.scm: Refine a comment about low-level port
      functions.  Move call-with-foo-port, with-input-from-foo, etc later in
      the file, and define using `parameterize' instead of `dynamic-wind'.
      Somewhat cleaner, and avoids thunk? checks for "swaports" in the old
      implementation.

commit 124bc316a6831bc842c25769731e92181fd8a711
Author: Andy Wingo <address@hidden>
Date:   Tue Mar 6 00:44:01 2012 +0100

    load parameters earlier in boot-9
    
    * module/ice-9/boot-9.scm: Move parameters earlier in the boot process.
      The new with-output-to-port code will use it.

commit d867c7496ce6caea7f449658306b85db3c95616c
Author: Andy Wingo <address@hidden>
Date:   Tue Mar 6 00:36:25 2012 +0100

    slight tweak to file-exists?, file-is-directory?
    
    * module/ice-9/boot-9.scm (file-exists?, file-is-directory?): For the
      fallback cases, use open-input-file instead of open-file with
      OPEN_READ.

commit f7955da9663804812a914b17459483d376db42aa
Author: Andy Wingo <address@hidden>
Date:   Tue Mar 6 00:34:59 2012 +0100

    bootstrapping shenanigans in `warn'
    
    * module/ice-9/boot-9.scm (warn): Don't use with-output-to-port, as
      we'll move that definition after the psyntax boot.

commit f28dc43c959f74164daf9eeabfdd6ccb19556f60
Author: Andy Wingo <address@hidden>
Date:   Tue Mar 6 00:33:14 2012 +0100

    more clear comments in boot-9.scm
    
    * module/ice-9/boot-9.scm: Update comment header for language
      primitives.

commit 0f6f5fb7f83e6faa3547a116cd6b43d947f429b0
Author: Andy Wingo <address@hidden>
Date:   Tue Mar 6 00:31:13 2012 +0100

    remove deprecated close-io-port
    
    * module/ice-9/boot-9.scm (close-io-port): Remove proc that was
      deprecated in 2.0.

commit 418321524a3a239326cb96f2dbd03c16cea9b762
Author: Andy Wingo <address@hidden>
Date:   Mon Mar 5 23:33:50 2012 +0100

    inline ice-9/r4rs.scm into ice-9/boot-9.scm
    
    * module/ice-9/boot-9.scm: Inline r4rs.scm, in anticipation of more
      refactorings.
    
    * module/ice-9/r4rs.scm: Remove.
    * module/Makefile.am: Update.

-----------------------------------------------------------------------

Summary of changes:
 module/Makefile.am      |    1 -
 module/ice-9/boot-9.scm |  414 +++++++++++++++++++++++++++++++++++------------
 module/ice-9/r4rs.scm   |  245 ----------------------------
 3 files changed, 310 insertions(+), 350 deletions(-)
 delete mode 100644 module/ice-9/r4rs.scm

diff --git a/module/Makefile.am b/module/Makefile.am
index 865bf89..e161b9c 100644
--- a/module/Makefile.am
+++ b/module/Makefile.am
@@ -183,7 +183,6 @@ SYSTEM_BASE_SOURCES =                               \
   system/base/target.scm
 
 ICE_9_SOURCES = \
-  ice-9/r4rs.scm \
   ice-9/r5rs.scm \
   ice-9/deprecated.scm \
   ice-9/and-let-star.scm \
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 68f54a7..8fbddd0 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -186,10 +186,105 @@ If there is no handler at all, Guile prints an error and 
then exits."
 
 
 
-;;; {R4RS compliance}
+;;; {Language primitives}
 ;;;
 
-(primitive-load-path "ice-9/r4rs")
+;; These are are the procedural wrappers around the primitives of
+;; Guile's language: @apply, @call-with-current-continuation, etc.
+;;
+;; Usually, a call to a primitive is compiled specially.  The compiler
+;; knows about all these kinds of expressions.  But the primitives may
+;; be referenced not only as operators, but as values as well.  These
+;; stub procedures are the "values" of apply, dynamic-wind, and other
+;; such primitives.
+;;
+(define (apply fun . args)
+  (@apply fun (apply:nconc2last args)))
+(define (call-with-current-continuation proc)
+  (@call-with-current-continuation proc))
+(define (call-with-values producer consumer)
+  (@call-with-values producer consumer))
+(define (dynamic-wind in thunk out)
+  "All three arguments must be 0-argument procedures.
+Guard @var{in} is called, then @var{thunk}, then
+guard @var{out}.
+
+If, any time during the execution of @var{thunk}, the
+continuation of the @code{dynamic_wind} expression is escaped
+non-locally, @var{out} is called.  If the continuation of
+the dynamic-wind is re-entered, @var{in} is called.  Thus
address@hidden and @var{out} may be called any number of
+times.
address@hidden
+ (define x 'normal-binding)
address@hidden x
+ (define a-cont
+   (call-with-current-continuation
+     (lambda (escape)
+       (let ((old-x x))
+         (dynamic-wind
+           ;; in-guard:
+           ;;
+           (lambda () (set! x 'special-binding))
+
+           ;; thunk
+           ;;
+           (lambda () (display x) (newline)
+                   (call-with-current-continuation escape)
+                   (display x) (newline)
+                   x)
+
+           ;; out-guard:
+           ;;
+           (lambda () (set! x old-x)))))))
+
+;; Prints:
+special-binding
+;; Evaluates to:
address@hidden a-cont
+x
address@hidden normal-binding
+ (a-cont #f)
+;; Prints:
+special-binding
+;; Evaluates to:
address@hidden a-cont  ;; the value of the (define a-cont...)
+x
address@hidden normal-binding
+a-cont
address@hidden special-binding
address@hidden lisp"
+  (@dynamic-wind in (thunk) out))
+
+
+
+;;; {Low-Level Port Code}
+;;;
+
+;; These are used to request the proper mode to open files in.
+;;
+(define OPEN_READ "r")
+(define OPEN_WRITE "w")
+(define OPEN_BOTH "r+")
+
+(define *null-device* "/dev/null")
+
+(define (open-input-file str)
+  "Takes a string naming an existing file and returns an input port
+capable of delivering characters from the file.  If the file
+cannot be opened, an error is signalled."
+  (open-file str OPEN_READ))
+
+(define (open-output-file str)
+  "Takes a string naming an output file to be created and returns an
+output port capable of writing characters to a new file by that
+name.  If the file cannot be opened, an error is signalled.  If a
+file with the given name already exists, the effect is unspecified."
+  (open-file str OPEN_WRITE))
+
+(define (open-io-file str) 
+  "Open file with name STR for both input and output."
+  (open-file str OPEN_BOTH))
 
 
 
@@ -218,13 +313,11 @@ If there is no handler at all, Guile prints an error and 
then exits."
 (define current-warning-port current-error-port)
 
 (define (warn . stuff)
-  (with-output-to-port (current-warning-port)
-    (lambda ()
-      (newline)
-      (display ";;; WARNING ")
-      (display stuff)
-      (newline)
-      (car (last-pair stuff)))))
+  (newline (current-warning-port))
+  (display ";;; WARNING " (current-warning-port))
+  (display stuff (current-warning-port))
+  (newline (current-warning-port))
+  (car (last-pair stuff)))
 
 
 
@@ -1182,6 +1275,211 @@ VALUE."
 
 (provide 'record)
 
+
+
+;;; {Parameters}
+;;;
+
+(define <parameter>
+  ;; Three fields: the procedure itself, the fluid, and the converter.
+  (make-struct <applicable-struct-vtable> 0 'pwprpr))
+(set-struct-vtable-name! <parameter> '<parameter>)
+
+(define* (make-parameter init #:optional (conv (lambda (x) x)))
+  (let ((fluid (make-fluid (conv init))))
+    (make-struct <parameter> 0
+                 (case-lambda
+                   (() (fluid-ref fluid))
+                   ((x) (let ((prev (fluid-ref fluid)))
+                          (fluid-set! fluid (conv x))
+                          prev)))
+                 fluid conv)))
+
+(define (parameter? x)
+  (and (struct? x) (eq? (struct-vtable x) <parameter>)))
+
+(define (parameter-fluid p)
+  (if (parameter? p)
+      (struct-ref p 1)
+      (scm-error 'wrong-type-arg "parameter-fluid"
+                 "Not a parameter: ~S" (list p) #f)))
+
+(define (parameter-converter p)
+  (if (parameter? p)
+      (struct-ref p 2)
+      (scm-error 'wrong-type-arg "parameter-fluid"
+                 "Not a parameter: ~S" (list p) #f)))
+
+(define-syntax parameterize
+  (lambda (x)
+    (syntax-case x ()
+      ((_ ((param value) ...) body body* ...)
+       (with-syntax (((p ...) (generate-temporaries #'(param ...))))
+         #'(let ((p param) ...)
+             (if (not (parameter? p))
+                        (scm-error 'wrong-type-arg "parameterize"
+                                   "Not a parameter: ~S" (list p) #f))
+             ...
+             (with-fluids (((struct-ref p 1) ((struct-ref p 2) value))
+                           ...)
+               body body* ...)))))))
+
+
+
+;;; Current ports as parameters.
+;;;
+
+(let ((fluid->parameter
+       (lambda (fluid conv)
+         (make-struct <parameter> 0
+                      (case-lambda
+                        (() (fluid-ref fluid))
+                        ((x) (let ((prev (fluid-ref fluid)))
+                               (fluid-set! fluid (conv x))
+                               prev)))
+                      fluid conv))))
+  (define-syntax-rule (port-parameterize! binding fluid predicate msg)
+    (begin
+      (set! binding (fluid->parameter (module-ref (current-module) 'fluid)
+                                      (lambda (x)
+                                        (if (predicate x) x
+                                            (error msg x)))))
+      (hashq-remove! (%get-pre-modules-obarray) 'fluid)))
+  
+  (port-parameterize! current-input-port %current-input-port-fluid
+                      input-port? "expected an input port")
+  (port-parameterize! current-output-port %current-output-port-fluid
+                      output-port? "expected an output port")
+  (port-parameterize! current-error-port %current-error-port-fluid
+                      output-port? "expected an output port"))
+
+
+
+;;; {Warnings}
+;;;
+
+(define current-warning-port
+  (make-parameter (current-error-port)
+                  (lambda (x)
+                    (if (output-port? x)
+                        x
+                        (error "expected an output port" x)))))
+
+
+
+;;; {High-Level Port Routines}
+;;;
+
+(define (call-with-input-file str proc)
+  "PROC should be a procedure of one argument, and STR should be a
+string naming a file.  The file must already exist. These procedures
+call 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 values yielded by the procedure are 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."
+  (let ((p (open-input-file str)))
+    (call-with-values
+      (lambda () (proc p))
+      (lambda vals
+        (close-input-port p)
+        (apply values vals)))))
+
+(define (call-with-output-file str proc)
+  "PROC should be a procedure of one argument, and STR should be a
+string naming a file.  The behaviour is unspecified if the file 
+already exists. These procedures call 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 values yielded by the procedure are 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."
+  (let ((p (open-output-file str)))
+    (call-with-values
+      (lambda () (proc p))
+      (lambda vals
+        (close-output-port p)
+        (apply values vals)))))
+
+(define (with-input-from-port port thunk)
+  (parameterize ((current-input-port port))
+    (thunk)))
+
+(define (with-output-to-port port thunk)
+  (parameterize ((current-output-port port))
+    (thunk)))
+
+(define (with-error-to-port port thunk)
+  (parameterize ((current-error-port port))
+    (thunk)))
+
+(define (with-input-from-file file thunk)
+  "THUNK must be a procedure of no arguments, and 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 `current-input-port', 
+and the THUNK is called with no arguments.
+When the THUNK returns, the port is closed and the previous
+default is restored.  Returns the values yielded by THUNK.  If an
+escape procedure is used to escape from the continuation of these
+procedures, their behavior is implementation dependent."
+  (call-with-input-file file
+   (lambda (p) (with-input-from-port p thunk))))
+
+(define (with-output-to-file file thunk)
+  "THUNK must be a procedure of no arguments, and 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 `current-output-port', 
+and the THUNK is called with no arguments.
+When the THUNK returns, the port is closed and the previous
+default is restored.  Returns the values yielded by THUNK.  If an
+escape procedure is used to escape from the continuation of these
+procedures, their behavior is implementation dependent."
+  (call-with-output-file file
+   (lambda (p) (with-output-to-port p thunk))))
+
+(define (with-error-to-file file thunk)
+  "THUNK must be a procedure of no arguments, and 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 `current-error-port', 
+and the THUNK is called with no arguments.
+When the THUNK returns, the port is closed and the previous
+default is restored.  Returns the values yielded by THUNK.  If an
+escape procedure is used to escape from the continuation of these
+procedures, their behavior is implementation dependent."
+  (call-with-output-file file
+   (lambda (p) (with-error-to-port p thunk))))
+
+(define (with-input-from-string string thunk)
+  "THUNK must be a procedure of no arguments.
+The test of STRING  is opened for
+input, an input port connected to it is made, 
+and the THUNK is called with no arguments.
+When the THUNK returns, the port is closed.
+Returns the values yielded by THUNK.  If an
+escape procedure is used to escape from the continuation of these
+procedures, their behavior is implementation dependent."
+  (call-with-input-string string
+   (lambda (p) (with-input-from-port p thunk))))
+
+(define (with-output-to-string thunk)
+  "Calls THUNK and returns its output as a string."
+  (call-with-output-string
+   (lambda (p) (with-output-to-port p thunk))))
+
+(define (with-error-to-string thunk)
+  "Calls THUNK and returns its error output as a string."
+  (call-with-output-string
+   (lambda (p) (with-error-to-port p thunk))))
+
+(define the-eof-object (call-with-input-string "" (lambda (p) (read-char p))))
+
 
 
 ;;; {Booleans}
@@ -1231,7 +1529,7 @@ VALUE."
       (lambda (str)
         (->bool (stat str #f)))
       (lambda (str)
-        (let ((port (catch 'system-error (lambda () (open-file str OPEN_READ))
+        (let ((port (catch 'system-error (lambda () (open-input-file str))
                            (lambda args #f))))
           (if port (begin (close-port port) #t)
               #f)))))
@@ -1242,8 +1540,8 @@ VALUE."
         (eq? (stat:type (stat str)) 'directory))
       (lambda (str)
         (let ((port (catch 'system-error
-                           (lambda () (open-file (string-append str "/.")
-                                                 OPEN_READ))
+                           (lambda ()
+                             (open-input-file (string-append str "/.")))
                            (lambda args #f))))
           (if port (begin (close-port port) #t)
               #f)))))
@@ -2930,98 +3228,6 @@ module '(ice-9 q) '(make-q q-length))}."
 
 
 
-;;; {Parameters}
-;;;
-
-(define <parameter>
-  ;; Three fields: the procedure itself, the fluid, and the converter.
-  (make-struct <applicable-struct-vtable> 0 'pwprpr))
-(set-struct-vtable-name! <parameter> '<parameter>)
-
-(define* (make-parameter init #:optional (conv (lambda (x) x)))
-  (let ((fluid (make-fluid (conv init))))
-    (make-struct <parameter> 0
-                 (case-lambda
-                   (() (fluid-ref fluid))
-                   ((x) (let ((prev (fluid-ref fluid)))
-                          (fluid-set! fluid (conv x))
-                          prev)))
-                 fluid conv)))
-
-(define (parameter? x)
-  (and (struct? x) (eq? (struct-vtable x) <parameter>)))
-
-(define (parameter-fluid p)
-  (if (parameter? p)
-      (struct-ref p 1)
-      (scm-error 'wrong-type-arg "parameter-fluid"
-                 "Not a parameter: ~S" (list p) #f)))
-
-(define (parameter-converter p)
-  (if (parameter? p)
-      (struct-ref p 2)
-      (scm-error 'wrong-type-arg "parameter-fluid"
-                 "Not a parameter: ~S" (list p) #f)))
-
-(define-syntax parameterize
-  (lambda (x)
-    (syntax-case x ()
-      ((_ ((param value) ...) body body* ...)
-       (with-syntax (((p ...) (generate-temporaries #'(param ...))))
-         #'(let ((p param) ...)
-             (if (not (parameter? p))
-                        (scm-error 'wrong-type-arg "parameterize"
-                                   "Not a parameter: ~S" (list p) #f))
-             ...
-             (with-fluids (((struct-ref p 1) ((struct-ref p 2) value))
-                           ...)
-               body body* ...)))))))
-
-
-;;;
-;;; Current ports as parameters.
-;;;
-
-(let ((fluid->parameter
-       (lambda (fluid conv)
-         (make-struct <parameter> 0
-                      (case-lambda
-                        (() (fluid-ref fluid))
-                        ((x) (let ((prev (fluid-ref fluid)))
-                               (fluid-set! fluid (conv x))
-                               prev)))
-                      fluid conv))))
-  (define-syntax-rule (port-parameterize! binding fluid predicate msg)
-    (begin
-      (set! binding (fluid->parameter (module-ref (current-module) 'fluid)
-                                      (lambda (x)
-                                        (if (predicate x) x
-                                            (error msg x)))))
-      (module-remove! (current-module) 'fluid)))
-  
-  (port-parameterize! current-input-port %current-input-port-fluid
-                      input-port? "expected an input port")
-  (port-parameterize! current-output-port %current-output-port-fluid
-                      output-port? "expected an output port")
-  (port-parameterize! current-error-port %current-error-port-fluid
-                      output-port? "expected an output port"))
-
-
-
-;;;
-;;; Warnings.
-;;;
-
-(define current-warning-port
-  (make-parameter (current-error-port)
-                  (lambda (x)
-                    (if (output-port? x)
-                        x
-                        (error "expected an output port" x)))))
-
-
-
-
 ;;; {Running Repls}
 ;;;
 
diff --git a/module/ice-9/r4rs.scm b/module/ice-9/r4rs.scm
deleted file mode 100644
index 072c8c6..0000000
--- a/module/ice-9/r4rs.scm
+++ /dev/null
@@ -1,245 +0,0 @@
-;;;; r4rs.scm --- definitions needed for libguile to be R4RS compliant
-;;;; Jim Blandy <address@hidden> --- October 1996
-
-;;;;   Copyright (C) 1996, 1997, 1998, 2000, 2001, 2006, 2010, 2011 Free 
Software Foundation, Inc.
-;;;; 
-;;;; This library is free software; you can redistribute it and/or
-;;;; modify it under the terms of the GNU Lesser General Public
-;;;; License as published by the Free Software Foundation; either
-;;;; version 3 of the License, or (at your option) any later version.
-;;;; 
-;;;; This library is distributed in the hope that it will be useful,
-;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;;;; Lesser General Public License for more details.
-;;;; 
-;;;; You should have received a copy of the GNU Lesser General Public
-;;;; License along with this library; if not, write to the Free Software
-;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
USA
-
-(eval-when (compile)
-  (set-current-module (resolve-module '(guile))))
-
-
-;;;; apply and call-with-current-continuation
-
-;;; The deal with these is that they are the procedural wrappers around the
-;;; primitives of Guile's language. There are about 20 different kinds of
-;;; expression in Guile, and e.g. @apply is one of them. (It has to be that way
-;;; to preserve tail recursion.)
-;;;
-;;; Usually we recognize (apply foo bar) to be an instance of @apply, but in 
the
-;;; case that apply is passed to apply, or we're bootstrapping, we need a
-;;; trampoline -- and here they are.
-(define (apply fun . args)
-  (@apply fun (apply:nconc2last args)))
-(define (call-with-current-continuation proc)
-  (@call-with-current-continuation proc))
-(define (call-with-values producer consumer)
-  (@call-with-values producer consumer))
-(define (dynamic-wind in thunk out)
-  "All three arguments must be 0-argument procedures.
-Guard @var{in} is called, then @var{thunk}, then
-guard @var{out}.
-
-If, any time during the execution of @var{thunk}, the
-continuation of the @code{dynamic_wind} expression is escaped
-non-locally, @var{out} is called.  If the continuation of
-the dynamic-wind is re-entered, @var{in} is called.  Thus
address@hidden and @var{out} may be called any number of
-times.
address@hidden
- (define x 'normal-binding)
address@hidden x
- (define a-cont
-   (call-with-current-continuation
-     (lambda (escape)
-       (let ((old-x x))
-         (dynamic-wind
-           ;; in-guard:
-           ;;
-           (lambda () (set! x 'special-binding))
-
-           ;; thunk
-           ;;
-           (lambda () (display x) (newline)
-                   (call-with-current-continuation escape)
-                   (display x) (newline)
-                   x)
-
-           ;; out-guard:
-           ;;
-           (lambda () (set! x old-x)))))))
-
-;; Prints:
-special-binding
-;; Evaluates to:
address@hidden a-cont
-x
address@hidden normal-binding
- (a-cont #f)
-;; Prints:
-special-binding
-;; Evaluates to:
address@hidden a-cont  ;; the value of the (define a-cont...)
-x
address@hidden normal-binding
-a-cont
address@hidden special-binding
address@hidden lisp"
-  (@dynamic-wind in (thunk) out))
-
-
-;;;; Basic Port Code
-
-;;; Specifically, the parts of the low-level port code that are written in 
-;;; Scheme rather than C.
-;;;
-;;; WARNING: the parts of this interface that refer to file ports
-;;; are going away.   It would be gone already except that it is used
-;;; "internally" in a few places.
-
-
-;;; OPEN_READ, OPEN_WRITE, and OPEN_BOTH are used to request the
-;;; proper mode to open files in.
-;;;
-;;; If we want to support systems that do CRLF->LF translation, like
-;;; Windows, then we should have a symbol in scmconfig.h made visible
-;;; to the Scheme level that we can test here, and autoconf magic to
-;;; #define it when appropriate.  Windows will probably just have a
-;;; hand-generated scmconfig.h file.
-(define OPEN_READ "r")
-(define OPEN_WRITE "w")
-(define OPEN_BOTH "r+")
-
-(define *null-device* "/dev/null")
-
-(define (open-input-file str)
-  "Takes a string naming an existing file and returns an input port
-capable of delivering characters from the file.  If the file
-cannot be opened, an error is signalled."
-  (open-file str OPEN_READ))
-
-(define (open-output-file str)
-  "Takes a string naming an output file to be created and returns an
-output port capable of writing characters to a new file by that
-name.  If the file cannot be opened, an error is signalled.  If a
-file with the given name already exists, the effect is unspecified."
-  (open-file str OPEN_WRITE))
-
-(define (open-io-file str) 
-  "Open file with name STR for both input and output."
-  (open-file str OPEN_BOTH))
-
-(define close-io-port close-port)
-
-(define (call-with-input-file str proc)
-  "PROC should be a procedure of one argument, and STR should be a
-string naming a file.  The file must
-already exist. These procedures call 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 values yielded by the procedure are 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."
-  (let ((p (open-input-file str)))
-    (call-with-values
-      (lambda () (proc p))
-      (lambda vals
-        (close-input-port p)
-        (apply values vals)))))
-
-(define (call-with-output-file str proc)
-  "PROC should be a procedure of one argument, and STR should be a
-string naming a file.  The behaviour is unspecified if the file 
-already exists. These procedures call 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 values yielded by the procedure are 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."
-  (let ((p (open-output-file str)))
-    (call-with-values
-      (lambda () (proc p))
-      (lambda vals
-        (close-output-port p)
-        (apply values vals)))))
-
-(define (with-input-from-port port thunk)
-  (let* ((swaports (lambda () (set! port (set-current-input-port port)))))
-    (dynamic-wind swaports thunk swaports)))
-
-(define (with-output-to-port port thunk)
-  (let* ((swaports (lambda () (set! port (set-current-output-port port)))))
-    (dynamic-wind swaports thunk swaports)))
-
-(define (with-error-to-port port thunk)
-  (let* ((swaports (lambda () (set! port (set-current-error-port port)))))
-    (dynamic-wind swaports thunk swaports)))
-
-(define (with-input-from-file file thunk)
-  "THUNK must be a procedure of no arguments, and 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 `current-input-port', 
-and the THUNK is called with no arguments.
-When the THUNK returns, the port is closed and the previous
-default is restored.  Returns the values yielded by THUNK.  If an
-escape procedure is used to escape from the continuation of these
-procedures, their behavior is implementation dependent."
-  (call-with-input-file file
-   (lambda (p) (with-input-from-port p thunk))))
-
-(define (with-output-to-file file thunk)
-  "THUNK must be a procedure of no arguments, and 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 `current-output-port', 
-and the THUNK is called with no arguments.
-When the THUNK returns, the port is closed and the previous
-default is restored.  Returns the values yielded by THUNK.  If an
-escape procedure is used to escape from the continuation of these
-procedures, their behavior is implementation dependent."
-  (call-with-output-file file
-   (lambda (p) (with-output-to-port p thunk))))
-
-(define (with-error-to-file file thunk)
-  "THUNK must be a procedure of no arguments, and 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 `current-error-port', 
-and the THUNK is called with no arguments.
-When the THUNK returns, the port is closed and the previous
-default is restored.  Returns the values yielded by THUNK.  If an
-escape procedure is used to escape from the continuation of these
-procedures, their behavior is implementation dependent."
-  (call-with-output-file file
-   (lambda (p) (with-error-to-port p thunk))))
-
-(define (with-input-from-string string thunk)
-  "THUNK must be a procedure of no arguments.
-The test of STRING  is opened for
-input, an input port connected to it is made, 
-and the THUNK is called with no arguments.
-When the THUNK returns, the port is closed.
-Returns the values yielded by THUNK.  If an
-escape procedure is used to escape from the continuation of these
-procedures, their behavior is implementation dependent."
-  (call-with-input-string string
-   (lambda (p) (with-input-from-port p thunk))))
-
-(define (with-output-to-string thunk)
-  "Calls THUNK and returns its output as a string."
-  (call-with-output-string
-   (lambda (p) (with-output-to-port p thunk))))
-
-(define (with-error-to-string thunk)
-  "Calls THUNK and returns its error output as a string."
-  (call-with-output-string
-   (lambda (p) (with-error-to-port p thunk))))
-
-(define the-eof-object (call-with-input-string "" (lambda (p) (read-char p))))


hooks/post-receive
-- 
GNU Guile



reply via email to

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