What, if any, does not meet this definition of letrec in a Schema?

R5RS provides suggested macro definitions for syntax library forms:

http://schemers.org/Documents/Standards/R5RS/HTML/r5rs-ZH-10.html#%_sec_7.3

Which also defines letrec, in a very complex way, of course, not the way I would define it, I would simply use:

(define-syntax letrec2
  (syntax-rules ()
    ((letrec2 ((name val) ...) body bodies ...)
     ((lambda ()
       (define name val) ...
       body bodies ...)))))

As far as I understand the semantics of letrec, which I use very often as a named let. It works this way, however, since I had my share of debates with philosophers who think they can simply refute the special theory of relativity or established phonological theories, I know that when you think that you have a simple solution to a complex problem, possibly WRONG. There must be some time when this macro does not satisfy the semantics of letrec else, which they probably would use.

In this definition, the definitions are local to the letrec body, they can refer to each other for mutual recursion, I'm not quite sure what (if any) is wrong.

+5
source share
4 answers

, , , , , , R5RS.

http://community.schemewiki.org/?scheme-faq-macros

"letrec", , , -, , R5RS , -, "" . , ...

, R5RS , ...

0

, , , , R5RS.

letrec R5RS. . 6.2.2 .

, R5RS:

, , , . , , , , , .

edit1: r5rs- letrec. PLT 4.2.5 /r 5rs/main.ss

(define-syntax (r5rs:body stx)
(syntax-case stx (let)
  [(_ (let () . body))
   #'(let () . body)]
  [_
   ;; Convert internal definitions to `r5rs:letrec', as opposed
   ;; to `letrec'.
...

PLT- R5RS letrec R5RS. , DrScheme .

+5

R5RS , letrec . . , ; :

A <body> , letrec.

, letrec .

, letrec lambda desugar internal letrec, lambda letrec , , , - ...; -)

+3
source
Good question.

I think the sequence problem defineis this:

"The evaluation order of the expression expr ... is not defined, so the program should not evaluate the reference to any of the variables associated with the letrec expression before all values โ€‹โ€‹have been calculated"

Here: http://www.scheme.com/tspl4/binding.html#./binding:s20

0
source

All Articles