Lua lied to me :(

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
LuaWeaver
Party member
Posts: 183
Joined: Wed Mar 02, 2011 11:15 pm
Location: Ohio, USA

Lua lied to me :(

Post by LuaWeaver »

Well, this happened.

Code: Select all

for i=1,nil do end
That errors, of course:
>'for' limit must be a number

So I go and do this:

Code: Select all

for i=1,0/0 do end
That doesn't error! Now, go:

Code: Select all

print(0/0) --> -nan
nan is not a number, so why is for letting me use it as a limit? :death:
"your actions cause me to infer your ego is the size of three houses" -finley
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Lua lied to me :(

Post by slime »

LuaWeaver wrote:nan is not a number, so why is for letting me use it as a limit? :death:
Ah, but it is! :)

Code: Select all

print(type(0/0))
http://en.wikipedia.org/wiki/NaN#Encoding
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Lua lied to me :(

Post by raidho36 »

Reminds me of:
> issue #666: LÖVE crashes when I try to crash it.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Lua lied to me :(

Post by T-Bone »

I've never thought of this before. It's kind of like Wine except even more obvious :)
User avatar
Xgoff
Party member
Posts: 211
Joined: Fri Nov 19, 2010 4:20 am

Re: Lua lied to me :(

Post by Xgoff »

ieee probably should have called it something else, like "not representable" or something :(

reminds me of a past thread on the lua mailing list where someone suggested lua expressions that would have resulted in nan should return nil instead, because "not a number". NOPE.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 237 guests