lua-users home
lua-l archive

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


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Eike Decker wrote:
[...]
> Lua.org, 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
dg@cowlark.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkm2fe0ACgkQf9E0noFvlzhetwCdET7dEPyVQnnXqccMl1dLUQha
tcAAnRjIrex4P9NVYI/y3d/inf+UDSNX
=/cS/
-----END PGP SIGNATURE-----