lua-users home
lua-l archive

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


On Mar 26, 2014, at 2:16 PM, Rena <hyperhacker@gmail.com> wrote:

> 
> This is true. You could just as easily write:
> #if !(HAVE_BIT_OPS && HAVE_INTEGERS)
> instead of:
> #if LUA_VERSION < 53
> 
> though I find myself wondering how you get a simple version check like that wrong. :-)
> 
> -- 
> Sent from my Game Boy.

One horrible problem is that Windows reports major/minor version numbers as two discrete values. it’s amazing how many coders get checking for >= wrong in such a case:

— Check for OS version >= 2.1
local osmajor, osminor = OS.getversion()

— Incorrect solution 1
function CheckOSVersion(major, minor)
	return (major >= osmajor) and (minor >= osminor)
end

— Incorrect solution 2
function CheckOSVersion(major, minor)
	return (major == osmajor) and (minor >= osminor)
end

When I was at MS we found approx 15% of apps used solution 2 and 8% of apps used solution 2. Sigh.

—Tim