Condition を投げる人

誰も困らなさそうな非互換を見つけたのでとりあえずメモだけ残しとく。

Common Lisp では condition 投げられたとき*1に、どの関数で投げたかで処理系の反応(デバッガ起動するか否か)が変わる。

;;; Clozure CL にて
? (setq c (make-condition 'simple-condition :format-control "Hi")
        e (make-condition 'simple-error :format-control "Bah!!"))
#<SIMPLE-ERROR #x8AFD5D6>

;;; signal で投げると nil を返す
? (signal c)
NIL
? (signal e)
NIL

;;; error で投げるとデバッガ起動
? (error c)
> Error: Hi
> While executing: CCL::TOPLEVEL-EVAL, in process listener(1).
> Type :POP to abort, :R for a list of available restarts.
> Type :? for other options.
1 > :pop

? (error e)
> Error: Bah!!
> While executing: CCL::TOPLEVEL-EVAL, in process listener(1).
> Type :POP to abort, :R for a list of available restarts.
> Type :? for other options.
1 > :pop

デバッガの表示とかは違うけど SBCL でも基本一緒。

xyzzy はどう投げたかに関わらず、投げられた condition によって反応(ダイアログ出るか否か*2)が変わる。

(setq c (make-condition 'simple-condition :format-string "Hi")
      e (make-condition 'simple-error :format-string "Bah!!"))
=> #S(simple-error format-string "Bah!!" format-arguments nil)

(signal c)
=> nil

(signal e)
;; エラーダイアログが出る
Bah!!

(error c)
=> nil

(error e)
;; エラーダイアログが出る
Bah!!

*1:細かいこと言うと、投げられてから誰にも捕まらずにトップレベルまで伝わったとき

*2:反応は設定の「エラーをマイルドに」とかその辺でも変わる。