|
On 4/14/2016 12:26 PM, Thijs Schreijer wrote:
....This works by the way with Google (try googling f(x) = x^(1/3) and you will see the graph of the function also for the negative x-axis).I didn't know Google could do that. Very nice!
One of the many things I enjoy about the Lua-L is the relatively high probability of learning something I didn't know I needed to know, and not just about Lua.
Google's ability to infer what you really *meant* to ask can range from downright spooky to amazingly handy. I knew about calculations and unit conversions, but had never tripped over the graph feature.
Touching back to the OP's original question, Lua has many features that are specified by reference to either the C standard or to your chosen tool chain's implementation.
This is a great strength because it allows the implementation to just call pow() and sin() in the implementation of math.pow() and math.sin() without burdening the implementation with extra requirements on the supported domain and range.
It is a great weakness when typical C runtimes choose to dump core and crash when unexpected parameters are seen. One effect of this is the extra effort that is used to protect os.date() in Lua 5.2 and later from passing non-standard format specifiers to strftime(). In Lua 5.2 and earlier this was not done, and Lua scripts that happened to use C99 features running in Lua built in a C89 environment would frequently cause problems.
It also means that there are plenty of portability pitfalls even for otherwise innocent Lua scripts. The core interpreter can be built entirely without floating point arithmetic, for instance, and that will certainly trip up scripts that assumed that (5/2)*2 would be reasonably close to 5.
-- Ross Berteig Ross@CheshireEng.com Cheshire Engineering Corp. http://www.CheshireEng.com/