>>    Point of my patch is separeting two tables for its purpose.
>>      * A table for interned check, it has very short lifetime.
>
> IMO this is overkill: you are creating a table at every conversion of list and
> dict values and then discarding the table. A simpler solution is to only
> intern them while converting the values to Lua. Please see the attached patch.

Because, interned objects are distinuguished by C native pointer
 as light userdata you know.
The C native pointer be able to reused.
And when it is reused, there are posibility that its contents are not same.
This is a cause of the bug which I pointed out at top of this thread.

But interned objects are required, that I wrote last mail.

>>      * A table to manage lifecycle's buffer/window, it has long lifetime.
>
> Why do you need a table for that? A simple reference, as it was before, would
> work, no?

It is too complicated.

Those buffer/window objects are stored in the ENVIRON table twice.
Like this:

   a) env[lightudata] = udata
   b) env[udata] = true

a) is very reasonable, it represent lifetime of the vim's object.
If env[lightudata] == nil, that buffer/window is deleted on vim and it
is invalid for Lua.
This is very simple and reasonable.

The problem is b). It is too difficult.
Describing what is happen, is difficult too... it releated with cache
of interned object.

As I wrote, cache of interned objects should have short lifetime.
if_lua manages its short lifetime by using "value weak table".
It is the reason that the ENVIRON table is marked as "value weak table",
 and also why b) is required.

So, my understanding is like below:

  1. Marked ENVIRON table as "value weak table" for interned cache.
  2. Reuse the table for managing lifetime of buffer/window (see a).
  3. OMG, a) is garbage collected automatically (by "value weak")!
  4. Ah we can avoid to be garbage collected when store it as key too (see b).

...it is too complex, isn't it?
If buffer/window objects are stored in normal table (not "weak table"),
 b) is not required.


BTW: As Bram wrote, we need some test set for if_lua.
Luis, can you wrote those?


Best regards
-- 
MURAOKA Taro <[email protected]>

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

Raspunde prin e-mail lui