Commit 31e1b1a0 authored by Erick's avatar Erick

Added the PORT? primitive

parent 069ca95e
......@@ -18,7 +18,7 @@
;; USA.
;; Author: Erick Gallesio [eg@unice.fr]
;; Creation date: 26-Nov-2000 18:19 (eg)
;; Last file update: 9-Dec-2007 20:31 (eg)
;; Last file update: 27-Aug-2008 12:44 (eg)
;;
;; ======================================================================
......@@ -449,6 +449,7 @@ be accessed as a normal port with the standard Scheme primitives.])
(insertdoc 'call-with-input-string)
(insertdoc 'call-with-output-string)
(insertdoc 'output-port?)
(insertdoc 'port?)
(insertdoc 'output-string-port?)
(insertdoc 'output-file-port?)
(insertdoc 'output-virtual-port?)
......
......@@ -4,7 +4,7 @@
;;;
;;; This code is in the public domain.
;;;
;;; Last file update: 13-Dec-2007 12:38 (eg)
;;; Last file update: 27-Aug-2008 12:45 (eg)
;;;
......@@ -259,7 +259,7 @@
(define char-code-limit 256)
;;@ MOST-POSITIVE-FIXNUM is used in modular.scm
(define most-positive-fixnum #x0FFFFFFF)
(define most-positive-fixnum (greatest-fixnum))
;;@ Return argument
(define (identity x) x)
......@@ -353,7 +353,7 @@
((r rb) (open-input-file filename))
((w wb) (open-output-file filename))
(else (slib:error 'open-file 'mode? modes))))
(define (port? obj) (or (input-port? obj) (output-port? obj)))
(define (call-with-open-ports . ports)
(define proc (car ports))
(cond ((procedure? proc) (set! ports (cdr ports)))
......@@ -416,7 +416,9 @@
;;@ At this point SLIB:LOAD must be able to load SLIB files.
(define slib:load slib:load-source)
(define program-arguments argv)
(define (program-arguments)
(cons (program-name)
(argv)))
(define current-time current-seconds)
......@@ -440,7 +442,9 @@
(let* ((srfi-name (format "srfi-~a" i))
(srfi (string->symbol srfi-name)))
(when (srfi-0-feature-implementation-file srfi)
(stklos:provide srfi-name)))))
(stklos:provide srfi-name))
;; Clean result
(set! slib:features (filter symbol? slib:features)))))
;;;
;;; Redefine require/provide so that symbols use SLIB one and strings use STk one
......
;;;;
;;;; srfi-96.stk -- SRFI-96 support
;;;;
;;;; Copyright © 2008 Erick Gallesio - Polytech'Nice-Sophia <eg@unice.fr>
;;;;
;;;;
;;;; This program is free software; you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
;;;; the Free Software Foundation; either version 2 of the License, or
;;;; (at your option) any later version.
;;;;
;;;; This program 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 General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU General Public License
;;;; along with this program; if not, write to the Free Software
;;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
;;;; USA.
;;;;
;;;; Author: Erick Gallesio [eg@unice.fr]
;;;; Creation date: 27-Aug-2008 11:48 (eg)
;;;; Last file update: 27-Aug-2008 11:53 (eg)
;;;;
(require "STklos.init")
(provide "srfi-96")
/*
This file was automatically generated by make-C-boot
This is a dump of the image in file /misc/home/eg/Projects/STklos/lib/boot.img3
This is a dump of the image in file /home/eg/Projects/STklos/lib/boot.img3
***DO NOT EDIT BY HAND***
*/
......
/*
* p o r t . c -- ports implementation
*
* Copyright 1993-2007 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
* Copyright 1993-2008 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -20,7 +20,7 @@
*
* Author: Erick Gallesio [eg@unice.fr]
* Creation date: 17-Feb-1993 12:27
* Last file update: 4-Jul-2007 12:36 (eg)
* Last file update: 27-Aug-2008 12:45 (eg)
*
*/
......@@ -117,6 +117,19 @@ DEFINE_PRIMITIVE("output-port?", output_portp, subr1, (SCM port))
return MAKE_BOOLEAN(OPORTP(port));
}
/*
<doc EXT port?
* (port? obj)
*
* Returns |#t| if |obj| is an input port or an output port,
* otherwise returns #f.
doc>
*/
DEFINE_PRIMITIVE("port?", portp, subr1, (SCM port))
{
return MAKE_BOOLEAN(PORTP(port));
}
/*
<doc EXT interactive-port?
......@@ -1483,6 +1496,7 @@ int STk_init_port(void)
/* and its associated primitives */
ADD_PRIMITIVE(input_portp);
ADD_PRIMITIVE(output_portp);
ADD_PRIMITIVE(portp);
ADD_PRIMITIVE(interactive_portp);
ADD_PRIMITIVE(current_input_port);
ADD_PRIMITIVE(current_output_port);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment