[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Feature proposal: \x## notation in strings
- From: John Passaniti <john.passaniti@...>
- Date: Thu, 12 Mar 2009 09:53:47 -0400
On Thu, Mar 12, 2009 at 7:38 AM, John Hind <john.hind@zen.co.uk> wrote:
> In an ideal world we’d lose string escapes altogether and have compile-time
> concatenating with coercion of numeric constants to single-character
> strings, and compiler-defined constants for the common ASCII control codes:
>
> Mystring = “something”..[23]..”something else”..[0x33]..[CR]
Except that Lua doesn't do the string concatenation at compile-time.
Having this happen at run-time isn't much better than coming up with a
function to transform a string literal into another string literal
(the variations on the X'1f' suggestion).
In C, you concatenate string literals at compile time by simply
putting them next to each other. Why not take that same idea and mix
it with yours:
Mystring = "something" 23 "something else" 0x33
I would limit this to string literals created at lex-time, so your
"CR" on the end wouldn't work and any function calls wouldn't work
either as they would be at run-time.