[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [Q] simple translator from Lua to Java Script and PHP
- From: Javier Guerra Giraldez <javier@...>
- Date: Sun, 30 Nov 2008 00:55:21 -0500
On Sunday 30 November 2008, KHMan wrote:
> Javier Guerra Giraldez wrote:
> > On Saturday 29 November 2008, Fabien wrote:
> >> I've just written and put online an AST --> Lua source converter. While
> >> it doesn't translate into a different target language, it shows how to
> >> systematically walk through an AST, to produce a different
> >> representation of it. This makes it a decent starting point for a Lua
> >> --> anything-else converter, although it wasn't its original purpose
> >
> > [snip]
> > still, having the AST easily readable is a big first step towards a
> > Lua -->anything-else compiler.
>
> Apart from an AST, I think one other critical piece of
> infrastructure is the symbol management stuff. It's pretty much a
> requirement for any serious work on locals/upvalues and globals,
> as I found when doing optimization of local names in LuaSrcDiet.
> The other allocated stuff are the constants and prototypes, which
> is more straightforward. Activation (or visibility) time of local
> variables is pretty critical.
right; scoping is another place where Lua's strict adherence to design
principles creates high impedance-mismatches with other language's
half-hearted implementations of the same concepts.
a non-well-thought guess is that to generate half-readable code in the target
language, most Lua local variables would have to be name-mangled to avoid
clashes with other-scoped/same-named variables. (assuming the target
language does support closures... could be far worse if it doesn't.
fortunately that's one thing JS does well enough, AFAICT)
> Once the facilities are in place, Lua's use of tables makes
> development pretty convenient. Assuming no memory pressure,
> cross-references are dead easy to make, lookups are dead easy,
> tables are native... and manipulating all those grammar bits and
> stuff becomes pretty convenient. At the very least, it would be an
> amazing prototyping platform.
not only that. GWT and Pyjamas are proving that there's a place for webapps
written in other languages and compiled into JS.
--
Javier
Attachment:
signature.asc
Description: This is a digitally signed message part.