Gauche デバッグメモ
以下、3点セットで使う。
- リーダーマクロ #?=
- (debug-print-width #f) ;; これを忘れると情報が一部しかでない。http://practical-scheme.net/gauche/man/gauche-refj_61.html#SEC166
- write-object http://practical-scheme.net/gauche/man/gauche-refj_57.html#SEC128 クラス定義をした場合。
コンパイル時の環境を保持するためのクラス
(define-class <env> () ((bindings :init-form (make-hash-table) :accessor bindings-of) (parent :init-keyword :parent :init-form #f :accessor parent-of))) (define-method write-object ((env <env>) port) (format port "#<env: bindings: ~a has-parent?: ~a~%" (length (hash-table-keys (bindings-of env))) (if (parent-of env) "yes" "no")) (hash-table-for-each (bindings-of env) (lambda (k v) (format port " ~a : ~s~%" k v))) (format port ">")) (debug-print-width #f)
注意として、しばらく悩んだので一応メモ。debug-print-width は変数ではなくて parameter という奴なので define しては駄目。
;; (define debug-print-width #f) ;; 間違い (debug-print-width #f) ;; 正しい