[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lpeg as a part of lua (was: An introduction to Lua)
- From: Dirk Laurie <dirk.laurie@...>
- Date: Sun, 22 Oct 2017 19:12:53 +0200
2017-10-22 17:42 GMT+02:00 firstname.lastname@example.org <email@example.com>:
> hi all! :)
> 2017-10-22 1:21 GMT+02:00 Charles Heywood <firstname.lastname@example.org>:
> >> Lua’s standard library includes regular expressions library
> > I think it's a good idea to mention LPeg possibly becoming a part of the
> > language, but Lua itself doesn't have regex - it has Lua patterns.
> can you tell me more about this one?
> my questions would be that where and when this came up; and what could
> we achieve if it would be included in lua instead of still being a
> standalone lib?
Much though one loves LPeg, it would be a major paradigm shift to put it in Lua.
1. LPeg is not an extension of Lua, it is an implementation of an
abstract idea in Lua. You are not really thinking in Lua when you
program a grammar, you are thinking in LPeg.
2. At present coroutines is the hardest concept in Lua, followed at
a respectable distance by stateless iterators like the generic 'for'
and metatables. LPeg is quite a bit harder than either of those.
3. Lua's existing pattern matching is quite powerful but simpler
to understand even than regular expressions.
Put another way: the issue is not what can you do with LPeg, it is
what can you do that you can't do with Lua patterns, and whether
that extra is sufficiently common to justify adding LPeg to Lua.