Gauche > Archives > 2026/04/03

2026/04/03 08:49:47 UTCkaki
#
えぇ…let-syntax のbodyがスコープに入っちゃうんですね(キモくないか?)。(begin ...) がよそからrenameされてくるなら実際上は見えないから問題にならないとはいえ。確かにそこのtransformer specからしか見えないとは書いてない。
2026/04/03 11:24:38 UTCshiro
#
あと、let-syntaxをletで囲っちゃうのはR6RSのlet-syntax splicingと互換性なさそうと思うんだけど。
2026/04/03 15:28:43 UTCleque
#
SRFI-147のreference implementationとしてはlet-syntaxはR7RSのsemanticsが念頭にあって、R6RSのsplicingなlet-syntax 等々は必要に応じてサポートしてねという感じっぽいですね
#
"mutatis mutandis to all other natively provided binding facilities for keywords, e.g. let-syntax/splicing or define-syntax-parameter. " https://srfi.schemers.org/srfi-147/srfi-147.html
2026/04/03 15:35:35 UTCleque
#
ところで、beginのdefinitionはlet-syntaxのbodyどころか他のclauseもスコープ入るように見えてそれでいいの感も
#
;; こういう理解
(let-syntax ((x (begin
                  (define x1 42)
                  ...
                  (syntax-rules ())))
             (y (begin
                  (define y1 42)
                  ...
                  (syntax-rules ()))))
  #f)
===
(let ()
  (begin
    (define x1 42)
    ...
    (begin
      (define y1 42)
      ...
      (let-syntax ((x (syntax-rules ()))
                   (y (syntax-rules ())))
        #f))))
2026/04/03 16:31:16 UTCkaki
#
私もそういう理解です>他のclauseも入る
#
ML読んでたら、この挙動の説明と共に
https://srfi-email.schemers.org/srfi-147/msg/4958409/
> The reasons for these rules are:
> 1) This SRFI should be implementable in R7RS-small.
> 2) The rules should be as intuitive as possible.
> 3) Sophisticated custom macro transformers (as the one in SRFI 148)
とあったので、とにかくR7RS-smallの範囲で実装できることを重視したかった(のとSRFI148で必要になるのかな?)と思いました。これが直感的とは到底思えませんが。
#
それぞれのbeginがそれぞれのマクロ展開によって挿入されるなら衝突しないからヨシ!ってことなんだと想像します。