Loading ...
Sorry, an error occurred while loading the content.

66276Re: if_lua patch

Expand Messages
  • Luis Carvalho
    Sep 1, 2012
      > Wondering whether you have repository with all these changes.

      No, since the patches are few and far between.

      > After encountering this error in if_py* found it in your interface also:
      > vim -u NONE -c 'let d={} | lua vim.eval("d")[""]=1' -c 'echo d'
      > outputs “{'': 1.0}” while it should output error and “{}”: vim does not allow empty keys in dictionaries (it does not look like it breaks something except that doing “d['']” results in an error).

      I don't think that's an error in if_lua: the documentation doesn't say
      anything about dictionaries not allowing empty strings as keys -- :help
      Dictionary only says that 'a key is always a String' -- and hence the absence
      of error when printing d in your example. What is not allowed is for you to
      read or set empty keys in Vim (using 'let'), but I don't want to replicate
      that in if_lua. For instance, you can do this:

      vim -u NONE -c 'let d={} | lua vim.eval("d")[""] = "empty"'
      -c 'for [k,v] in items(d) | echo "|".k."| -> ".v | endfor'

      So, to be consistent, if you set an empty key in if_lua, you can read or reset
      it there.

      > And you have missed another error:
      > vim -u NONE -c 'lua vim.eval("g:")["input"]=vim.funcref("tr")' -c 'call input("Yes?")'
      > results in an error “not enough arguments to tr” while it should result in an error “funcref variables must start with a capital” (see my patch to python interface [1] and extend() function [2]).

      There's no error here either. The problem is that tr() expects three
      arguments, and not that the variable must start with a capital letter (g:input
      already exists.) Try this:

      vim -u NONE -c 'lua vim.eval("g:").input=vim.funcref("tolower")'
      -c 'echo input("Yes?")'

      I think you're mixing the fact that Vim Funcref variables should start with a
      capital letter. Funcrefs in lua are just a value; for instance, this should

      :lua print(vim.funcref"tr"("<tag>", "<>", "{}"))
      " {tag}

      Thanks for the comments!


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

      Luis Carvalho (Kozure)
      lua -e 'print((("lexcarvalho@..."):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
    • Show all 13 messages in this topic