lua-users home
lua-l archive

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


On Tue, Mar 4, 2014 at 8:08 AM, Richard Hundt <richardhundt@gmail.com> wrote:
> On 3/4/14 9:00 AM, Dirk Laurie wrote:
>> Is LPeg useful enough to justify how very much larger
>> Lua's C source code will become if it is included?
>>
>> IMHO, if the gain will merely be that the ordinary user
>> would no longer need to build/download it separately
>> (which LuaRocks can do for you) and require it (which
>> takes one line of code), the answer is NO.
>>
>> On the other hand, if the Lua implementation itself exploits
>> it for its lexer/parser/VM encoder and its string library,
>> thus demonstrating how useful it can be while at the same
>> time providing some highly instructive well-written LPeg
>> code, the answer is YES!
>>
> Shameless plug, but you can try it already [1]. It should give you an
> idea of how it might be integrated. Feedback welcome.
>
> Nyanga statically links with LPeg, and although the grammar syntax is
> very similar to the 're.lua' module, it doesn't pass a string to
> 're.lua', but produces an LPeg grammar directly using the API.
>
> [1] https://github.com/richardhundt/nyanga#grammars
>


LPeg is much easier for me to use than Lua's pattern's. That is most
likely because I do not have any prior experience with PCRE. Unlike
Lua patterns, I can read an LPeg grammar out loud.

I'm wondering:

How would Lua evolve with a first class "pattern" type? That is,
merely adding "pattern" as a type would have an impact, because you
could check for it as an argument and respond differently. There might
be other definitions of "first class" that I'm blind to and that might
be interesting, as well.

Could Lua's patterns be implemented in LPeg? If you removed the
existing pattern code, then added LPeg + Lua patterns, then what is
the size/performance difference?

What kind of uses does Lua get thrown into, if LPeg is included in the
standard library?

I think that its presence in the standard library would change Lua's
perceived potential uses. For example, if I'm not writing a module, I
use LPeg whenever it is called for. When I am writing a module, I
avoid it because I can usually do what I need to do without adding
that dependency. I assume others go through a similar math. If that's
true, LPeg's presence will change Lua, but not for the worse.

Perhaps it would be viewed as a nod to Lua in the role of a desktop /
server language.

-Andrew