For Gauche 0.9.5


Next: , Previous: , Up: Library modules - R7RS integration   [Contents][Index]

10.4 scheme.base - R7RS base library

Module: scheme.base

Exports bindings of R7RS (scheme base) library. From R7RS programs, those bindings are available by (import (scheme base)).

Bindings common to Gauche’s built-ins

The following syntaxes and procedures are the same as Gauche’s builtins:

Primitive expression types
quote if include include-ci lambda
Derived expression types
cond case and or when unless cond-expand let let* letrec letrec*
let-values let*-values begin do make-parameter parameterize
guard quasiquote unquote unquote-splicing case-lambda
Macros
let-synatx letrec-syntax syntax-rules syntax-error define-syntax
Variable definitions
define define-values
Record type definitions
define-record-type
Equivalence predicates
eqv? eq? equal?
Numbers
number? complex? real? rational? integer? exact? exact-integer?
= < > <= >= zero? positive? negative? odd? even? max min + * - / abs
floor/ floor-quotient floor-remainder
truncate/ truncate-quotient truncate-remainder
quotient modulo remainder gcd lcm numerator denominator
floor ceiling truncate round rationalize square exact-integer-sqrt
expt inexact exact number->string string->number
Booleans
not boolean? boolean=?
Pairs and lists
pair? cons car cdr set-car! set-cdr! caar cadr cdar cddr null? list?
make-list list length append reverse list-tail list-ref list-set!
memq memv member assq assv assoc list-copy
Symbols
symbol? symbol=? symbol->string string->symbol
Characters
char? char=? char<? char>? char<=? char>=? char->integer integer->char
Strings
string? make-string string string-length string-ref string-set!
string=? string<? string>? string<=? string>=? substring string-append
string->list list->string string-copy string-copy! string-fill!
Vectors
vector? make-vector vector vector-length vector-ref vector-set!
vector->list list->vector vector->string string->vector
vector-copy vector-copy! vector-append vector-fill!
Control features
procedure? apply map call-with-current-continuation call/cc 
values call-with-values dynamic-wind
Exception
error
Environments and evaluation
scheme-report-environment null-environment
Input and output
input-port? output-port? port? current-input-port current-output-port
current-error-port close-port close-input-port close-output-port
open-input-string open-output-string get-output-string
read-char peek-char read-line eof-object? eof-object char-ready?
newline write-char

Bytevector utilities

Function: bytevector n …
Function: bytevector? obj
Function: make-bytevector size :optional byte
Function: bytevector-length bv
Function: bytevector-u8-ref bv index
Function: bytevector-u8-set! bv index byte
Function: bytevector-copy bv :optional start end
Function: bytevector-copy! to at from :optional start end
Function: bytevector-append bv …

[R7RS] R7RS’s bytevector is Gauche’s u8vector.

These are equivalent to gauche.uvector’s u8vector, u8vector?, make-u8vector, u8vector-length, u8vector-ref, u8vector-set!, u8vector-copy, u8vector-copy!, and u8vector-append, respectively. (see Uniform vectors).

These two procedures are the same as the ones in gauche.unicode module (see Unicode transfer encodings):

utf8->string string->utf8

Control features

Function: string-map proc str …
Function: string-for-each proc str …

[R7RS] These take different arguments from string-map and string-for-each in SRFI-13 (see SRFI-13 String mapping), so provided only in scheme.base module to avoid confusion.

If you pass only one string argunemt, however, it works exactly the same way in both srfi-13 and scheme.base.

Function: raise obj
Function: raise-continuable obj

[R7RS] Gauche’s raise may return if obj isn’t a <serious-condition>. Distinguishing continuable and noncontinuable exception throw by the procedure has an issue when your exception handler wants to reraise the condition (you don’t know if the original condition is raised by raise or raise-continuable!). Yet R7RS adoted that model, so we compel.

R7RS raise is a wrapper of Gauche’s raise, which throws an error if Gauche’s raise returns.

R7RS raise-continuable is currently just an alias of Gauche’s raise—as long as you don’t pass <serious-condition>, it may return. It is not exactly R7RS comformant—it won’t return if you pass <serious-condition> or object of one of its subclasses (e.g. <error>), but it’s weired to expect returning from raising <error>, isn’t it?

Function: error-object? exc

[R7RS] Defined as (condition-has-type? exc <error>))

Function: error-object-message exc

[R7RS] If exc is a <message-condition>, returns its message-prefix slot; otherwise, returns an empty string.

Function: error-object-irritants exc

[R7RS] If exc is a <message-condition>, returns its message-args slot; otherwise, returns an empty string.

Function: read-error? exc

[R7RS] Defined as (condition-has-type? e <read-error>)).

Function: file-error? exc

[R7RS] At this moment, Gauche doesn’t have distinct <file-error> condition, but most file errors are thrown as one of <system-error>s. This procedure checks error code of <system-error> and returns #t if the error is likely to be related to the filesystem.

Input and output

Function: textual-port? port
Function: binary-port? port

[R7RS] Gauche’s port can handle both, so these are equivalent to port?.

Function: input-port-open? iport
Function: output-port-open? oport

[R7RS] Checks whether iport/oport is an input/output port and it is not closed.

Function: open-input-bytevector u8vector
Function: open-output-bytevector
Function: get-output-bytevector port

[R7RS] These are basically the same as open-input-uvector, open-output-uvector and get-output-uvector in gauche.vport (see Virtual ports), except that R7RS procedures only deal with <u8vector>.

Function: read-u8 :optional iport
Function: peek-u8 :optional iport
Function: u8-ready? :optional iport

[R7RS] These are aliases to read-byte, peek-byte and byte-ready?, respectively.

Function: read-bytevector size :optional iport

[R7RS] Equivalent to (read-uvector <u8vector> size iport). See Uvector block I/O.

Function: read-bytevector! bv :optional iport start end

[R7RS] An alias to read-uvector!. See Uvector block I/O.

Function: write-string string :optional oport start end

[R7RS] If the optional start and end arguments are omitted, it is the same as (display string oport). The optional arguments restricts the range of string to be written.

Function: write-u8

[R7RS] An alias to write-byte.

Function: write-bytevector bv :optional oport start end

[R7RS] Equivalent to write-uvector. See Uvector block I/O.

Function: flush-output-port :optional oport

[R7RS] An alias to flush.

Function: features

[R7RS] Returns a list of symbols of supported feature identifiers, recognized by cond-expand (see Feature conditional).


Next: , Previous: , Up: Library modules - R7RS integration   [Contents][Index]