lua-users home
lua-l archive

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


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

Asko Kauppi wrote:
[...]
> I.e. replacing a number of a= a..b with table.concat() is way outside of the 
> optimization scope, right?

Oddly enough, that's exactly what Java does. If you say:

String s = s1 + s2 + s3 + "foo";

...then (assuming s1, s2, s3 are strings) what you usually *get* is along the
lines of:

String s = new
StringBuilder().append(s1).append(s2).append(s3).append("foo").toString();

So, provided the Lua compiler can prove that all the parameters are actually
strings (and that the string metatable hasn't been extended or table.concat()
has been modified) then yes, this is a perfectly valid optimisation.

- --
┌── dg@cowlark.com ─── http://www.cowlark.com ───────────────────
│ "Parents let children ride bicycles on the street. But parents do not
│ allow children to hear vulgar words. Therefore we can deduce that cursing
│ is more dangerous than being hit by a car." --- Scott Adams
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGIo6yf9E0noFvlzgRAsFEAKCMRc5fj9r+FTwivINWERzQuU7qXwCdFE8Q
HJC8WEHuvq/L7vkGqjtJHbI=
=B2QN
-----END PGP SIGNATURE-----