lua-users home
lua-l archive

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

Hash: SHA1

Eike Decker wrote:
>, PUC-Rio
>> ="\102\101\100\099\098\097"
> fedcba
> It is just the way I would expect it - at least in Lua. I would have
> been surprised if \0xx would be an octal notation in Lua....

Actually, rather than octal, I was expecting \099 to become an embedded
NUL followed by '99', as the docs specifically say:

> Strings in Lua can contain any 8-bit value, including embedded zeros,
> which can be specified as '\0'.

So I'd argue that this *still* contains a nasty surprise, just not the
one I was expecting. (I see now that \0 is just a subset of \ddd, and
not a special case. Perhaps a clarification would be useful?)

Also, I notice that the standard set of C string escapes uses the same
syntax (and with the same gotcha), but for octal escapes, rather than
Lua's decimal. I'd argue that this is confusing, given that a lot of Lua
programmers are embedding Lua in C; but as there's no way of changing
things now without breaking backwards compatibility in truly horrible
ways, such an argument would be pointless!

- --
David Given
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla -