Hi Muraoka-san,

> I have investigated your new patch.
> (Sorry, I can't try it yet.  It is working time in Japan.)
> I have new several questions.
> 
>   Q1. upvalue is available on 5.1 too. Why don't you use it for 5.1?

It is being used.

>   Q2. What is host object of upvalue?

By definition, the closure (function).

> I have to write additional for Q2.
> In my understanding, upvalue is generated for each C functions which
> registered to Lua, is it right?
> So there are different upvalues for different C functions.
> if_lua register many C functions (for window/buffer) to Lua.
> Those functions expect that upvalue is a same object.
> I'm afraid it can't be worked...
> Can you point out my understanding is wrong or right?

No, the upvalue is generated only once: it is a single table. An upvalue is
just an external local variable, and tables are bound to variables as
references (there is no copy). So the upvalues are the same table for all
functions that share it:

  :lua getup1 = function(f) local _, u = debug.getupvalue(f, 1) return u end
  :lua print(getup1(vim.eval), getup1(vim.beep)) -- same upvalue
 
> > I understand the problem, but not the reason for your solution.
> 
> For future maintainance (not you nor me).
> I like to make source code be easy to read, and represents its logic
> directry. ;-)

That's a valid reason, but it doesn't fix bugs. There are two solutions to
this problem: as it is now, list/dict values are simply being "serialized" to
Lua tables, so there is no point in interning them, and hence my solution
(which, IMHO, is simple and easy enough to read :)); the other approach is to
have list/dict userdata in Lua instead of tables -- this would require some
work, but it might be better since the objects (userdata) will always be
consistent with their Vim counterparts and can thus be interned. The first
solution was in my last patch; I'll try and come up with another patch for the
second solution by the end of the day, and we can compare them.

Cheers,
Luis

-- 
Computers are useless. They can only give you answers.
                -- Pablo Picasso

-- 
Luis Carvalho (Kozure)
lua -e 'print((("[email protected]"):gsub("(%u+%.)","")))'

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