lua-users home
lua-l archive

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


Pierre-Yves Gérardy <pygy79@gmail.com> writes:
> Following the floating point discussion, I tried to look for a compilation
> of the various gotchas Lua beginners encounter, but I couldn't find one, so
> I decided to compile one...
>
> Right now, I can think of two of them:
>
> - Floating point inaccuracies. A simplified version of Patrick Rapin's
> "math.compare (x,y,delta)" [1] could be proposed as a workaround.

This isn't a "Lua gotcha" though -- it's an issue with pretty much any
programming languages that doesn't use decimal arithmetic (that is to
say, it's an issue with almost all of them)...

> - The fact that you have to declare locals before using them.

Er, sure...

I'm a bit confused as to how somebody can be tripped up by this though
-- if they have the concept of a "local variable" at all, then surely
they're acquainted with the notion of declaring them, as that's the
only way to make a local variable in 99% of programming languages
(ignoring function parameters, but presumably they're "special")...

(if they're _not_ familiar with the concept of local variables, then
their programs may suck, but Lua's behavior will presumably seem
natural, as they'll think all variables are global...)

-Miles

-- 
`The suburb is an obsolete and contradictory form of human settlement'