|
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] IMHO string escapes and their bastard cousins, format codes are
amongst the worst of the legacy of “C” and how anyone can describe
them as “principle of least surprise” defeats me. Certainly Windows
programmers get a very nasty surprise every time they forget to double up the
backslashes in file specifications! I’ve been programming in C for twenty
years now, and Lua for 5, and have found these conventions completely
un-learnable – I have to consult a reference book every time. But it is probably too late for change now and if we must have
escape code there may as well be a full set of the damn things! From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Joseph Stewart How about this instead: function binary(t) local r = {} for i=1,#t do if type(t[i]) == "number" then
t[i] = string.char(t[i]) end end return table.concat(t) end x = binary{"this",
0x81, "this", 0x33} I know this is less efficient than having the lexer do it,
but it's an option that works without any mods to the core. On Wed, Mar 11, 2009 at 5:17 PM, Sam Roberts <vieuxtech@gmail.com> wrote: On Wed, Mar 11, 2009 at 8:14 AM, Roberto Ierusalimschy All the arguments that apply to the usefulness of hex
literal
This is the only use I can think of where decimal is
routinely used to |
Attachment:
smime.p7s
Description: S/MIME cryptographic signature