I suggest, that you first consider, how would you do that in JS. You'll need to wrap that in functions:
actually what I want to achieve is something like this:
(create "fn_1" (let ((x))
#'(lambda ()
x))
"fn_2" (let ((x))
#'(lambda ()
x)))
and I expected these two "x" are lexical-scope separate and so
independent from each other.
However the compiled js code doesn't work as I expected.
On Thu, Oct 13, 2011 at 2:51 PM, Vsevolod Dyomkin <vseloved@gmail.com> wrote:
> Hi
> Actually the above code is correct.
> You can also use:
> - either
> (let (x)
> (create "fn" (lambda () x)))
> - or
> (create "x" nil
> "fn" (lambda () x)))
> depending on the JS semantics you want to get.
> vsevolod
>
>
> On Thu, Oct 13, 2011 at 8:40 AM, Canhua <dreameration@gmail.com> wrote:
>>
>> hi, all, I found that
>> (create "fn" (let ((x))
>> (lambda () x)))
>>
>> compiles to
>> { 'fn' : (x = null, function () {
>> return x;
>> }) }
>>
>> wherein the variable x may conflict with a variable with the same name
>> outside this code.
>> How may avoid this? How may I achieve "let over lambda" closure effect
>> as in common lisp?
>>
>> Thanks.
>>
>> _______________________________________________
>> parenscript-devel mailing list
>> parenscript-devel@common-lisp.net
>> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
>
>
> _______________________________________________
> parenscript-devel mailing list
> parenscript-devel@common-lisp.net
> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
>
>
_______________________________________________
parenscript-devel mailing list
parenscript-devel@common-lisp.net
http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel