[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Define in let
From: |
Ralf Mattes |
Subject: |
Re: Define in let |
Date: |
Wed, 21 Aug 2013 11:28:51 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Wed, Aug 21, 2013 at 08:52:02AM +0200, Panicz Maciej Godek wrote:
> 2013/8/20 David Pirotte <address@hidden>
>
> > 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
- Define in let, Dmitry Bogatov, 2013/08/20
- Re: Define in let, Thompson, David, 2013/08/20
- Re: Define in let, Taylan Ulrich B., 2013/08/20
- Re: Define in let, Ian Price, 2013/08/20
- Re: Define in let, Mike Gran, 2013/08/20
- Re: Define in let, John B. Brodie, 2013/08/20
- Re: Define in let, David Pirotte, 2013/08/20
Re: Define in let, Dmitry Bogatov, 2013/08/21