English 中文(简体)
lua中的准引语/引语?
原标题:quasiquote/quote in lua?
  • 时间:2010-04-30 20:24:25
  •  标签:
  • lua

在Lisp,我可以:

(a b c d e f g)

意 见

look up b, c, d, e, f, g
look up a; apply value of a to above

然后,我还可以:

`(a b c d e f g)

等于

 (list  a  b  c  d  e  f  g)

现在,在卢阿,我可以:

[snipplet 1]
foo = {
  Foo,
  {Cat, cat},
  {Dog, dog}
};

Which ends up most likely expanding into: { nil, { nil, nil}, {nil, nil}}

我确实想要的是:

[snipplet 2]
{ "Foo", {"Cat", "cat"}, {"Dog", "dog"}}

吗?

我认为,[第1号]比[第2号]更直观的认罪,但我所说的是pple。 2. 结 论

感谢!

最佳回答

这里没有星号,但你可以尝试这一长期解决办法:

setmetatable(_G,{__index=function (t,k) return k end})

这使得所有未界定的变量都与含有其名字的插图一样。

问题回答

考虑设立一个包含Lisp syntax的扼杀功能,并从中建立一个表格。





相关问题
Wrapping a Lua object for use in C++ with SWIG

Currently I know how to have C++ objects instantiated and passed around in Lua using SWIG bindings, what I need is the reverse. I am using Lua & C++ & SWIG. I have interfaces in C++ and ...

Can t lua_resume after async_wait?

I have some lua script that have some long running task like getting a web page so I make it yield then the C code handle get page job async, so the thread free to do other job and after a specify ...

How to remove a lua table entry by its key?

I have a lua table that I use as a hashmap, ie with string keys : local map = { foo = 1, bar = 2 } I would like to "pop" an element of this table identified by its key. There is a table.remove() ...

Lua plain string.gsub

I ve hit s small block with string parsing. I have a string like: footage/down/temp/cars_[100]_upper/cars_[100]_upper.exr and I m having difficulty using gsub to delete a portion of the string. ...

why do i get "attempt to call global require (a nil value)"?

I have 3 lua files, Init.lua, FreeCamera.lua and Camera.lua , init.lua calls require "Core.Camera.FreeCamera" Free Camera: module(...) require "Core.Camera.Camera" local M = {} FreeCamera = M M ...

热门标签