|
On 10/14/2013 11:25 AM, Carsten Fuchs wrote:
I think the main difference is that string converstions themselves are often not a simple function, so you can easily accept the overhead of a metamethod call. Also in all the programs that are not heavy on text manipulation the __toboolean would be called many more times, just think of all the while and if statements all over the code.Am 14.10.2013 10:32, schrieb steve donovan:On Mon, Oct 14, 2013 at 10:23 AM, Thomas Jericke <tjericke@indel.ch> wrote:I think it could be a to high performance hit to have a metamethod lookup oneach and every condition or logical expression of a program.True, plus making programs even more confusing...Well, a __tobool metamethod would just be a typecast, like __tostring.I'm certainly not feverish about this, but for consistency's sake, I think it would be nice to have either -- or none. ;-)
It wouldn't be a perfomance hit if you only use booleans for conditions and logic operations in your code though: if a ~= nil then ... would actuall not trigger the metamethod.
-- Thomas