[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Feature proposal: \x## notation in strings
- From: David Manura <dm.lua@...>
- Date: Wed, 11 Mar 2009 22:13:59 -0400
On Tue, Mar 10, 2009 at 7:03 PM, Ralph Hempel wrote:
> ...to make sure that a simple 10 line fix
> did not break thousands of lines of existing code....
Is this defined or undefined behavior in Lua 5.1?
assert( "\x10" == "x10" ) -- not [[\x10]]
assert( "\;" == ";") -- not [[\;]]
The refman[1] gives a list of "C-like escape sequences" that short
literal strings may contain. For long strings, it does say that
escape sequences are not interpreted. But for short strings, it is
not clear whether (1) other C-like escape sequences are allowed and
(2) if so how they are interpreted. Lua does interpret "\;" as ";",
so I would argue that this is an escape sequence, one undefined in the
manual.
Note that the above behavior permits Lhf's example
print(X"4c75612e6f7267") but does not permit an implementation like
print(X"\x4chello\x61"), which would be interpreted as
print(X"x4chellox61") prior to evaluation by X (and in fact also prior
to certain stages of Metalua processing).
[1] http://www.lua.org/manual/5.1/manual.html#2.1