Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!mit-eddie!killer!pollux!ti-csl!m2!gateley From: gateley@m2.csc.ti.com (John Gateley) Newsgroups: comp.lang.scheme Subject: Re: where define is legal Message-ID: <75453@ti-csl.csc.ti.com> Date: 21 Apr 89 18:26:23 GMT References: <8904201554.AA13117@spt.entity.com> Sender: news@ti-csl.csc.ti.com Reply-To: gateley@m2.UUCP (John Gateley) Organization: TI Computer Science Center, Dallas Lines: 30 In article <8904201554.AA13117@spt.entity.com> alms@spt.entity.COM (andrew lm shalit) writes: >(define (foo bool) > (if bool > (define (result) #true) > (define (result) #false)) > (result)) From the R^3S: Section 5.2 "Definitions are valid in some, but not all, contexts where expressions are allowed. They are valid only at the top level of a and, in some implementations, at the beginning of a . Section 5.2.1 describes top level definitions, and section 5.2.2 describes internal definitions. The above code can be rewritten as: (define result nil) ; dummy value for the variable result. (define (foo bool) (if bool (set! result (lambda () #true)) (set! result (lambda () #false))) (result)) You can use a local variable for result if you want. John gateley@tilde.csc.ti.com p.s. Hi Eric.