@ITに掲載したGaucheでメタプログラミングの正誤表
以前 @IT に書いた Gaucheでメタプログラミング ですが、オレンジニュースの角田さんが間違いを見つけてくれました ^^); ありがとうございます !!
間違いは現在修正されています
第3回 GaucheでRDBプログラミングの3ページ
最後の実行結果は以下が正しいです。
(ref yamada 'weight)の結果は 60 ではなく 62 です。
gosh> (define yamada (make <body> :height 170 :weight 60)) yamada gosh> (slot-ref yamada 'weight) 60 gosh> (slot-set! yamada 'weight 62) #<undef> gosh> (slot-ref yamada 'weight) 62 gosh> (ref yamada 'weight) 62 gosh> (set! (ref yamada 'weight) 63) #<undef> gosh> (weight-of yamada) 63 gosh> (set! (weight-of yamada) 66) #<undef> gosh> (bmi yamada) 22.837370242214536
第4回 Gaucheでテンプレートエンジンを作るの2ページ
最初のコードは正しくは以下です。
display関数に指定されていた *p* を消して下さい。またtemplate->s-exp関数定義の最後の閉じカッコが足りませんでした ^^);
(define (template->s-exp templ) (define (quote-display m) (format "(display ~s)" (m 1))) (if (not (#/<%/ templ)) templ (let* ((s (regexp-replace-all* templ #/<%=(.*?)%>/ "<% (display \\1) %>" #/%>(.*?)<%/ quote-display)) (str-s-exp (regexp-replace* s #/^(.*?)<%/ quote-display #/%>(.*?)$/ quote-display))) (read-from-string (string-append "(begin " str-s-exp ")"))))) (define (rendering-template templ) (eval (template->s-exp templ) (interaction-environment)))