Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!uwm.edu!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!apple!snorkelwacker!bloom-beacon!WRL.DEC.COM!bartlett From: bartlett@WRL.DEC.COM Newsgroups: comp.lang.scheme Subject: Re: Internal definitions, DEC Scheme->C Message-ID: <9006291615.AA28227@jove.pa.dec.com> Date: 29 Jun 90 16:15:43 GMT References: Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 43 In a previous message, Wayne Schou (math1205@waikato.ac.nz) suggested that the expression: (let ((a 1)) (define (f x) (define b (+ a x)) (define a 5) (+ a b)) (f 10)) should evaluate to either 20 or 16. >> As I see the Scheme description given in R^nRS, expressions in the body of f >> should be evaluated in sequence and therefore the above should return 16. >> Who agrees/disagrees? Disagree, according to R3RS,the effect of the program is undefined. Section 5.2.2 of R3RS defines internal defines in terms of letrec, so the above expression is really: (let ((a 1)) (letrec ((f (lambda (x) (letrec ((b (+ a x)) (a 5)) (+ a b))))) (f 10))) The last paragraph of section 4.2.2 of R3RS explains that a letrec of this form violates an important restriction. Quoting R3RS "it must be possible to evaluate each without referring to the value of any . If this restriction is violated, then the effect is undefined, and an error may be signalled during the evaluation of the s." >> Also in the DEC Scheme->C implementation the above expression returns the >> rather confusing value of 15. I assume this is caused by a having the value >> of 0 when the definition of b is evaluated. I think this is a bug! >> Who agrees/disagrees? Disagree as the value of the program is undefined. I will agree with you though that error signals on undefined operations are often more desirable than implementation specific values.