lua-users home
lua-l archive

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


> On 8 April 2010 11:57, Luiz Henrique de Figueiredo
> <lhf@tecgraf.puc-rio.br>wrote:
> 
> >  the best
> > solution is concatenation, really:
> >        a = "a long string"
> >          .."continues here without"
> >          .."line breaks"
> >
> 
> Agreed. and if constant folding for string concatenation was implemented,
> any downsides are removed....

Not exactly. A simple constant folding would only move the concatenation
from run time to compile time (which in Lua is not such a big
difference, unless the string is defined multiple times).  The compiler
would still create all those small strings and keep them alive, as they
are constants in the code.

The ideal would be "constant folding" at the lexical level, so that
only the final string is ever created; but the lexical level does not
know about precedence and other syntactical stuff...

-- Roberto