Hi,
2016/7/17 Sun 19:37:09 UTC+9 Ken Takata wrote:
> Hi itchyny,
>
> 2016/7/17 Sun 10:08:02 UTC+9 itchyny wrote:
> > 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.
>
> Could you try this experimental patch?
> https://bitbucket.org/k_takata/vim-ktakata-mq/src/962046ccfd7221dbb0bc29ed33e6c3d2a210e1be/lambda-update.patch?fileviewer=file-view-default
>
> Sorry, tests are not included yet.
Hmm, it seems it has some problems. SEGV occurs with test_alot.vim.
Regards,
Ken Takata
--
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.