On Wed, Aug 21, 2013 at 08:52:02AM +0200, Panicz Maciej Godek wrote:I'd say this is extremly contorted and non-schemish.
> 2013/8/20 David Pirotte <david@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))))
What's wrong with:
(lambda (arg) (+ a arg))))
(define foo
(let ((a 2))
This is the basic let-over-lambda closure ....