lua-users home
lua-l archive

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


Doug Rogers wrote:
[...]
> I work in the embedded arena, too, so I can sympathize with Ralph
> Hempel's gripe about RAM. The issue definitely comes up. But I'd still
> prefer the benefits of a simpler code base to those of constant folding.

As a compromise, it may be sensible to have a basic, working-and-reliable
compiler in the actual *engine*, and then to have a separate Lua-to-Lua
processor that takes off-line code and produces optimised code suitable for
deployment. (Or byte-code. It doesn't matter which.) If you could add syntax
for 'compiler hints' --- i.e., something that's ignored by the on-line
compiler --- it would allow you to annotate your code in a way that the
off-line compiler would recognise.

For example (making up syntax out of a hat):

local $const$ CONSTVAL = 4

The off-line compiler would see that I'd marked that as a constant, and would
not only produce error messages if I tried to write to it, but would use
constant folding to compile CONSTVAL+1 into a literal instead of an
expression. The on-line compiler would ignore the $const$ completely and
produce a normal local variable.

One of the reasons I bring this up is that this week I've been writing simple
games. (I'm vaguely planning to write up 'How to write a game in Lua in three
days' article --- if you're at 3GSM, drop round the Tao buses and ask to see
Binet.) These are intended for deployment on phones. I'd really like an
efficient optimising compiler; but I don't really want to have to ship the ---
big --- optimising compiler with each game. I'm aware I can use luac, but that
uses the on-line compiler which isn't that great. A decent off-line compiler
would really help me.

-- 
┌── dg@cowlark.com ─── http://www.cowlark.com ───────────────────
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out how to
│ use my telephone." --- Bjarne Stroustrup

Attachment: signature.asc
Description: OpenPGP digital signature