[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Matching multibyte alphabetical characters with LPeG
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 20 Jun 2012 09:48:25 -0300
> Also, why is l_newpf exposed through the registry?
> `lua_pushcfunction(L, (lua_CFunction)&l_newpf); /* new-pattern function */`
> I found this really odd: why not expose it directly (so I can link
> against lpeg);
This may change; the idea was exactly to avoid fixed links. Independent
libraries could be independently compiled.
> and why cast it (incorrectly) as a lua_CFunction? Why not a boxed userdata?
It is not incorrect. ANSI C ensures that all pointers to functions are
compatible. That is, if A and B are pointers to functions, we can
convert from A to B and back to A without loss. Now that Lua 5.2 has
light C functions, this looks like an interesting technique to store
pointers to functions in Lua (as long as Lua code has no access to
them).
-- Roberto