R6RS:翻訳:Standard Libraries:8.1 Condition types

R6RS:翻訳:Standard Libraries:8.1 Condition types

8.1 コンディション型

本章で述べる手続きは、「入出力エラー」により生じた例外的状況を検知したとき、 &i/o コンディション型の例外を通知する。

コンディション型と対応する述語やアクセサは (rnrs io ports (6)) と (rnrs io simple (6)) ライブラリの両方で公開されている。また、9 章で述べる (rnrs files (6)) ライブラリでも公開されている。

[condition type] &i/o

[procedure] (make-i/o-error)

[procedure] (i/o-error? obj)

このコンディション型は次のように定義することができる。

(define-condition-type &i/o &error
  make-i/o-error i/o-error?)

このコンディション型はより詳細は入出力エラーの上位型である。

[condition type] &i/o-read

[procedure] (make-i/o-read-error)

[procedure] (i/o-read-error? obj)

このコンディション型は次のように定義することができる。

(define-condition-type &i/o-read &i/o
  make-i/o-read-error i/o-read-error?)

このコンディション型は入出力処理を行なっているときに読み込みエラーの起こったことを表す。

[condition type] &i/o-write

[procedure] (make-i/o-write-error)

[procedure] (i/o-write-error? obj)

このコンディション型は次のように定義することができる。

(define-condition-type &i/o-write &i/o
  make-i/o-write-error i/o-write-error?)

このコンディション型は入出力処理を行なっているときに書き込みエラーの起こったことを表す。

[condition type] &i/o-invalid-position

[procedure] (make-i/o-invalid-posiiton-error position)

[procedure] (i/o-invalid-position-error obj)

[procedure] (i/o-error-position condition)

このコンディション型は次のように定義することができる。 (define-condition-type &i/o-invalid-position &i/o

  make-i/o-invalid-position-error
  i/o-invalid-position-error?
  (position i/o-error-position))

このコンディション型はファイル位置を無効な位置に設定しようとしたことを表す。 position はプログラムが設定しようとしたファイル位置でなければならない。このコンディションは範囲エラーであり、表明違反ではない。

[condition type] &i/o-filename

[procedure] (make-i/o-filename-error filename)

[procedure] (i/o-filename-error? obj)

[procedure] (i/o-error-filename condition)

このコンディション型は次のように定義することができる。

(define-condition-type &i/o-filename &i/o
  make-i/o-filename-error i/o-filename-error?
  (filename i/o-error-filename))

このコンディション型は名前着きのファイルに対する捜査中に入出力エラーの起こったことを表す。 filename はファイルの名前でなければならない。

[condition type] &i/o-file-protection

[procedure] (make-i/o-file-protection-error filename)

[procedure] (i/o-file-protection-error? obj)

このコンディション型は次のように定義することができる。

(define-condition-type &i/o-file-protection
    &i/o-filename
  make-i/o-file-protection-error
  i/o-file-protection-error?)

この型のコンディションは名前付きのファイルに対して操作を行おうとしたとき、充分なアクセス権限がなかったことを表す。

[condition type] &i/o-file-is-read-only

[procedure] (make-i/o-file-is-read-only-error filename)

[procedure] (i/o-file-is-read-only-error? obj)

このコンディション型は次のように定義することができる。

(define-condition-type &i/o-file-is-read-only
    &i/o-file-protection
  make-i/o-file-is-read-only-error
  i/o-file-is-read-only-error?)

この型のコンディションは読み込み専用の名前付きファイルに対して、それが書き込み可能であるという仮定のもとに操作を行ったことを表す。

[condition type] &i/o-file-already-exists

[procedure] (make-i/o-file-already-exists-error filename)

[procedure] (i/o-file-already-exists-error? obj)

このコンディション型は次のように定義することができる。

(define-condition-type &i/o-file-already-exists
    &i/o-filename
  make-i/o-file-already-exists-error
  i/o-file-already-exists-error?)

この型のコンディションは既に存在する名前付きのファイルに対して、それが存在しないものとして操作を行なったことを表現する。

[condition type] &i/o-file-does-not-exist

[procedure] (make-i/o-file-does-not-exist-error filename)

[procedure] (i/o-file-does-not-exist-error? obj)

&i/o-file-does-not-exist condition type (make-i/o-file-does-not-exist-error filename) procedure (i/o-file-does-not-exist-error? obj) procedure

このコンディション型は次のように定義することができる。

(define-condition-type &i/o-file-does-not-exist
    &i/o-filename
  make-i/o-file-does-not-exist-error
  i/o-file-does-not-exist-error?)

この型のコンディションは存在しない名前付きファイルに対して、あたかもそれが存在するかのように操作を行なったことを表現する。

[condition type] &i/o-port

[procedure] (make-i/o-port-error port)

[procedure] (i/o-port-error? obj)

[procedure] (i/o-error-port condition)

このコンディション型は次のように定義することができる。

(define-condition-type &i/o-port &i/o
  make-i/o-port-error i/o-port-error?
  (port i/o-error-port))

このコンディション型では入出力エラーに関連づけられたポートを指定する。 port はポートである。引き数としてポートを受け取る手続きにより通知されるコンディションは &i/o-port-error コンディションを含むべきである。


Last modified : 2008/03/13 16:28:33 UTC