It happened to me while re-implementing LPeg [0] as a pure Lua library[1].
While targeting Lua, the original is actually written in C. It compiles patterns to bytecode interpreted by a custom VM.
I was wary to write an interpreter in a language that's already interpreted and chose to compile patterns to Lua functions instead. It turns out that the most straightforward way to do that is by using closures higher level functions, in a way that I later learned was known as parser combinators...
While targeting Lua, the original is actually written in C. It compiles patterns to bytecode interpreted by a custom VM.
I was wary to write an interpreter in a language that's already interpreted and chose to compile patterns to Lua functions instead. It turns out that the most straightforward way to do that is by using closures higher level functions, in a way that I later learned was known as parser combinators...
————
0. http://www.inf.puc-rio.br/~roberto/lpeg/
1. https://github.com/pygy/LuLPeg