lua-users home
lua-l archive

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

David Manura wrote:
Though one could, I think the larger question is why. CPP has substantial limitations (e.g. looping and data structures). However, if you're given Lua, it's relatively simple to reuse the full power of Lua without the lpeg dependency: .

This is a bit of a tangent, but I've tried using m4-preprocessed C to implement a few personal projects. It gives me some of the conveniences and abstractions of C++ without the long compile times, hefty run-time library, and murky external linkage conventions. The problem with this is that m4 is a strange, strange beast that very few people want to deal with.

Going beyond this, one of the things I've thought about was allowing C to be metaprogrammed in Lua. This involves the parsing (not just lexing) of C from Lua so that Lua has access to the C parse tree.

Even without lexing, you could use lua to drive a text-based macro-processing step. With lexing, you can do a lot more, and it doesn't seem that hard. (Says someone who's never tried it.) Parsing gets you farther, but I'm not sure if the extra work is worth it.

What cases can you think of where full parsing is useful? Would a useful intermediate step be using lua to run some kind of m4 substitute? And do you know of such a project anywhere?