Hi ZyX,
2016/7/22 Fri 20:15:33 UTC+9 ZyX wrote:
> >> I was wrong regarding the consequences and why you should alter the
> >> GC: it is not memory leak because cycle is not GC’d. It is *crash*
> >> because Vim does not know that dictionary is referenced:
> >>
> >> ```VimL
> >> function F()
> >> let d = {}
> >> return {-> d}
> >> endfunction
> >> let L = F()
> >> call garbagecollect(1)
> >> call feedkeys(":echo L()\n", 'n')
> >> ```
> >>
> >> Save to `test.vim` and run as `vim -u NONE -i NONE -N -S test.vim`.
> >> When I use it in Vim with optimizations it crashes immediately:
Yes, I also noticed this. I tested with the following script:
function! Test_lambda_closure()
function! s:foo()
let x = [0]
return {-> [execute("let x[0] += 1"), x[0]][-1]}
endfunction
let l:F = s:foo()
call test_garbagecollect_now()
call assert_equal(1, l:F())
call assert_equal(2, l:F())
call assert_equal(3, l:F())
call assert_equal(4, l:F())
endfunction
I have updated the patch:
https://bitbucket.org/k_takata/vim-ktakata-mq/src/52c8d4fd0af2dd8bd2c79204dbbedd9ded874439/lambda-update.patch?at=default
Now it deals with GC. Also add some tests, reduce memory when local variables
or arguments are not used.
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.