~ chicken-core (chicken-5) 6eda778123408d57e78e6e87935dd7c588df724c
commit 6eda778123408d57e78e6e87935dd7c588df724c Author: felix <felix@call-with-current-continuation.org> AuthorDate: Sun May 2 00:21:36 2010 +0200 Commit: felix <felix@call-with-current-continuation.org> CommitDate: Sun May 2 00:21:36 2010 +0200 added port-closed? (contributed by Peter Bex) diff --git a/chicken.import.scm b/chicken.import.scm index 8f9e5850..3c27d302 100644 --- a/chicken.import.scm +++ b/chicken.import.scm @@ -174,6 +174,7 @@ open-input-string open-output-string parentheses-synonyms + port-closed? port-name port-position port? diff --git a/library.scm b/library.scm index e3204a43..ff3f63c5 100644 --- a/library.scm +++ b/library.scm @@ -1667,6 +1667,10 @@ EOF (and (%port? x) (not (##sys#slot x 1)) ) ) +(define (port-closed? p) + (##sys#check-port p 'port-closed?) + (##sys#slot p 8)) + ;;; Port layout: ; ; 0: FP (special) diff --git a/manual/Unit library b/manual/Unit library index c62f8fc0..d93e5203 100644 --- a/manual/Unit library +++ b/manual/Unit library @@ -207,6 +207,11 @@ different behavior. Write buffered output to the given output-port. {{PORT}} defaults to the value of {{(current-output-port)}}. +==== port-closed? + +<procedure>(port-closed? PORT)</procedure> + +Is the given {{PORT}} closed? ==== port-name diff --git a/types.db b/types.db index f9f366af..1e927dd2 100644 --- a/types.db +++ b/types.db @@ -221,6 +221,7 @@ (scheme-report-environment (procedure scheme-report-environment (#!optional fixnum) *)) (null-environment (procedure null-environment (#!optional fixnum) *)) (interaction-environment (procedure interaction-environment () *)) +(port-closed? (procedure port-closed? (port) boolean)) ;; chickenTrap