SapphireDensetsu / ypsilon

Automatically exported from code.google.com/p/ypsilon
Other
0 stars 0 forks source link

try this: #47

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
(define a 15)
(define (test c)
  (letrec ((a (+ c 13))
           (b (+ a 90)))
    (+ a b)))
(test 13)
(test 14)

error: binding construct attempt to reference uninitialized variable, use
'--warning' to perform expansion time check

Note that a is defined regardless of letrec.

Original issue reported on code.google.com by narutoca...@gmail.com on 10 Sep 2008 at 9:57

GoogleCodeExporter commented 8 years ago
According to discussions(*1) in comp.lang.scheme which I referenced to implement
letrec and letrec* in Ypsilon 0.9.6, I think letrec in expression:

> (define (test c)
>  (letrec ((a (+ c 13))
>           (b (+ a 90)))
>    (+ a b)))

is invalid and R6RS implementation is responsible to raise assertion-violation 
at
runtime(*2).

*1
http://groups.google.com/group/comp.lang.scheme/browse_thread/thread/a43607cc117
055f8/0334c1df3ebb85f9
http://groups.google.com/group/comp.lang.scheme/browse_thread/thread/a7d691b5ca8
7b94f/c7ce67ffc1f988ca

*2
This behavior is different from R5RS. In R5RS, an effect of such expression is
unspecified. For example,
Petite Chez(R5RS): Prints "Error: attempt to reference undefined variable a."
Scheme48(R5RS): Prints "Error: LETREC variable used before its value has been 
produced"
SCM(R5RS): Evaluate letrec as if letrec*.

Any comments very welcome. Thank you!

Original comment by y.fujita...@gmail.com on 13 Sep 2008 at 3:28