guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Define in let


From: John B. Brodie
Subject: Re: Define in let
Date: Tue, 20 Aug 2013 13:18:50 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130803 Thunderbird/17.0.8

On 08/20/2013 12:39 PM, Dmitry Bogatov wrote:
> 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?

use a lambda form rather than a define:

(letrec ((a 2)
             (foo (lambda (x) (+ a x))))
     (foo 3))

>
> Please, keep in CC, I am not subscribed.
>
> --
> Best regards, Dmitry Bogatov <address@hidden>,
> Free Software supporter and netiquette guardian.
>       git clone git://kaction.name/rc-files.git --depth 1
>       GPG: 54B7F00D
> Html mail and proprietary format attachments are forwarded to /dev/null.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]