[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: patch: C-style string lexing
- From: Mike Pall <mikelu-0801@...>
- Date: Thu, 31 Jan 2008 21:11:30 +0100
Mark Hamburg wrote:
> on 1/31/08 11:02 AM, Eric Tetz at erictetz@gmail.com wrote:
> > It's certainly no burden to *type*, but I think most programmers
> > find it unappealing to incur a performance penalty for the sake
> > of source beautification. If you've got 50 lines, Lua's creating
> > 48 strings of intermediate garbage just to concatenate them,
> > right?
>
> That's why we need constant folding in the compiler so that the compiled
> code only has one string.
Ok, let the parser concatenate the string. How is that better
than doing it at runtime? Most of these are used at the module
top-level and this runs only once.
Oh, you mean you're doing this in a loop? Well, it's rare to see
very long strings used inside a loop. For the few remaining cases
you can easily hoist them out of the loop (it's a common
programming idiom to use #defines/consts/locals to abstract long
messages).
[Or let a "sufficiently smart" JIT compiler do this for you.
Nope, LuaJIT 1.x won't do this for you -- it doesn't pay off
because it's too rare. But LuaJIT 2.x might do this as a
side-effect.]
--Mike