[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: What's up with token filters (Re: New operators?)
- From: David Given <dg@...>
- Date: Sun, 15 Apr 2007 01:45:09 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Fabien wrote:
[...]
> I should know, metalua would have been much faster to write if it did (although
> I understand the interest of not building it since you can avoid it). My point
> is that if you want to add syntax control features, the Lua Way of adding
> generic mechanisms instead of ad-hoc closed features would be to add explicit
> AST + control over it. I definitely realize it's a non-trivial change.
It occurs to me that a reasonably elegant way of implementing non-trivial
syntax modifications to Lua would be to have a totally separate, off-line
compiler --- most likely written in Lua --- that reads in a Lua chunk,
transforms it somehow, and then outputs it again as vanilla Lua source that
can be passed to the real interpreter.
This way we gain all the advantages of the amazingly fast stream-based
compiler, plus all the advantages of a complex AST-based compiler (which can
also do code optimisation), plus we maintain a clear distinction between the
Lua core language and the extended language (because they're implemented in
separate programs!).
If run-time compilation of extended language chunks was required, it ought to
be relatively straightforward to override load() to run the script through the
off-line compiler first.
- --
┌── dg@cowlark.com ─── http://www.cowlark.com ───────────────────
│ "Parents let children ride bicycles on the street. But parents do not
│ allow children to hear vulgar words. Therefore we can deduce that cursing
│ is more dangerous than being hit by a car." --- Scott Adams
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGIXWVf9E0noFvlzgRAqQjAJsFK+eb4xFJLlf3imzJi9+CVlIEJwCdGTic
7wSpkD5sTIL9m6d68CdfOp0=
=Y8K0
-----END PGP SIGNATURE-----