lua-users home
lua-l archive

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

On Oct 10, 2017, at 7:48 PM, Jonathan Goble <> wrote:

The bug in this second issue appears to be in the documentation, not the code, since there's no good reason why Lua should ignore an explicit start argument when the caret is given, and valid reasons why it shouldn't ignore the start argument. Consider a simple tokenizer that repeatedly matches consecutive tokens without skipping anything else; the pattern could be prefixed with a ^ and suffixed with a position capture, and on each iteration, the result from the previous position capture is fed to the next call as the start argument. In this case, you would rely on the ^ meaning "anchor to start point", and a nil result would mean a syntax error in whatever you're tokenizing.

I think the Lua docs are ok.

I would expect Lua to start at the ‘init’ position regardless of the presence of a carat anchor, and my reading of the term “subject string” in the docs would mean the string starting at the specified ‘init’ position (since this term occurs in a general discussion of pattern matching, not string.match). So the docs match the expected (by me) behavior. And you seem to say that in the paragraph above (and I agree with your reasoning).