On Wed, Aug 21, 2013 at 08:52:02AM +0200, Panicz Maciej Godek wrote: > 2013/8/20 David Pirotte <da...@altosw.be> > > > Hello, > > > > > It seems following is invalid: > > > > > > (let ((a 2)) > > > (define (foo x) (+ a x))) > > > > > > I prefer to reduce scope of variable as much as possible, so > > > I find this restriction unconvinent. Is is part of standard or technical > > > limitation? Is it any workaround? > > > > The Scheme's idiomatic way to achieve the effect that you > probably want would be > (define foo #f) > (let ((a 2)) > (set! foo (lambda (x) (+ a x))))
I'd say this is extremly contorted and non-schemish. What's wrong with: (define foo (let ((a 2)) (lambda (arg) (+ a arg)))) This is the basic let-over-lambda closure .... Cheers, Ralf Mattes