On Sunday, July 17, 2016 at 2:56:44 AM UTC+9, Bram Moolenaar wrote:
> Ken Hamada wrote:
> 
> > Hi Bram and Ken Takata.
> > 
> > I think there is some problem in variable substitution of lambda function.
> > 
> > echo ({y -> ({x -> x(y)(10)})({y -> y})})({z -> z})
> > 
> > yields an error `E121: Undefined variable: y`. I expect this expression 
> > yields 10. I tested on Vim 7.4.2048.
> > 
> > JavaScript:
> > (function(y){ return (function(x){ return x(y)(10); })(function(y){ return 
> > y; }); })(function(z){ return z; })
> > 
> > Python:
> > (lambda y: (lambda x: x(y)(10))(lambda y: y))(lambda z: z)
> > 
> > Ruby:
> > (lambda {|y| (lambda {|x| (x.call(y)).call(10)}).call(lambda {|y| 
> > y})}).call(lambda {|z| z})
> > 
> > All these expressions prints 10 as expected.
> 
> This is because Vim does not support a closure yet.  You are using this
> lambda:
>       {x -> x(y)(10)}
> You can see that "y" is not defined here.  It would come from the
> context, but that isn't supported.
> 

I see. Thanks for explanation.

Regards,
Ken Hamada

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui