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.

> Anyway, 7.4.2044 is surely a great advance in the history of Vim
> script. Thanks.

Glad you like it.

-- 
Luxury. We used to have to get out of the lake at three o'clock in the 
morning, clean the lake, eat a handful of hot gravel, go to work at the 
mill every day for tuppence a month, come home, and Dad would beat us 
around the head and neck with a broken bottle, if we were LUCKY!

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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