diff --git a/NEWS b/NEWS index 5a9c3e204..943de3428 100644 --- a/NEWS +++ b/NEWS @@ -169,6 +169,11 @@ Guile. Instead, use scm_memq, scm_memv, scm_member. +** New function: port? X + +Returns a boolean indicating whether X is a port. Equivalent to +`(or (input-port? X) (output-port? X))'. + * Changes to the gh_ interface * Changes to the scm_ interface diff --git a/libguile/ChangeLog b/libguile/ChangeLog index a47fef9cd..5b3a541a5 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,9 @@ +2000-11-04 Gary Houston + + * ports.c (scm_port_p): new function, implements "port?" which + is mentioned in R5RS. + * ports.h: declare scm_port_p. + 2000-11-01 Dirk Herrmann * backtrace.c (display_expression, display_error_body), fports.c diff --git a/libguile/ports.c b/libguile/ports.c index 3f952a60a..7476613a0 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -735,6 +735,16 @@ SCM_DEFINE (scm_output_port_p, "output-port?", 1, 0, 0, } #undef FUNC_NAME +SCM_DEFINE (scm_port_p, "port?", 1, 0, 0, + (SCM x), + "Returns a boolean indicating whether @var{x} is a port.\n" + "Equivalent to @code{(or (input-port? X) (output-port? X))}.") +#define FUNC_NAME s_scm_port_p +{ + return SCM_BOOL (SCM_PORTP (x)); +} +#undef FUNC_NAME + SCM_DEFINE (scm_port_closed_p, "port-closed?", 1, 0, 0, (SCM port), "Returns @code{#t} if @var{port} is closed or @code{#f} if it is open.") diff --git a/libguile/ports.h b/libguile/ports.h index 0b12af557..d4f884ee3 100644 --- a/libguile/ports.h +++ b/libguile/ports.h @@ -269,6 +269,7 @@ extern SCM scm_close_port (SCM port); extern SCM scm_close_all_ports_except (SCM ports); extern SCM scm_input_port_p (SCM x); extern SCM scm_output_port_p (SCM x); +extern SCM scm_port_p (SCM x); extern SCM scm_port_closed_p (SCM port); extern SCM scm_eof_object_p (SCM x); extern SCM scm_force_output (SCM port);