lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Lua mailing list,

I used Lua to create a GraphDB within my experimental DB, here is a writeup:
http://jaksprats.wordpress.com/2012/02/28/lightweight-oltp-data-platform/

I want to add support for the graph traversal language Gremlin:
https://github.com/tinkerpop/gremlin/wiki

The following:
g.v(1).out('knows').filter{it.age < 30}
is a gremlin traversal, that 
1.) starts at node1
2.) finds all outgoing nodes w/ relationship 'knows'
3.) and then filters, them returning only those w/ attribute 'age' less than 30

Being clever w/ __index, __newindex, & __call, I can figure out how to turn this nested table call into a series of graph function traversal directives.
The part that I can not figure out, & may not be possible in Lua, is the handling of the closure '{it.age < 30}'. This closure is denoted by '{}' which I do not believe is overridable in Lua, and the contents 'it.age < 30' contains real code, so they need to be evaluated.

Is there any magic that can turn '{it.age < 30}' into something like 'function step_3(it) return it.age < 30; end'

I dont think there is.

If there is not, does anyone have any suggestions on how to best implement a minimally modified Gremlin syntax that would fit smoothly into Lua's syntax

thanks, 
 jak