@grainloom huh, in ruby a void function just returns nil:
def nnn
nil
end
# => :nnn
def voidvoid
#noop
end
# => :voidvoid
nnn # => nil
voidvoid # => nil
nnn == voidvoid # => true
@bonzoesc yuh, in Lua there is actually a stack for the return values or something
in Python, you can return multiple things but it's actually just syntax sugar for returning a tuple, whereas in Lua you are pushing things onto a stack
eg. you can do
local a, nil1, nil2 = (function()return 1 end)()
-- a == 1 and nil1 == nil and nil2 == nil
@bonzoesc and you can also ignore a few returned values, this is often used instead of result types:
loadstring("bad source code")
will return nil and an error message
loadstring("return 1")
will return a funtion
if you don't expect an error then you get nil and trying to use that will sooner or later blow up
@bonzoesc
the proper way to handle that would be
local f = assert(loadstring(source_code))
if given a false-y value, assert will call error with its second parameter
@grainloom yeah, ruby does the destructuring assignment like that (but with Arrays since no tuples)
not sure how i feel about it all, kinda neat that all these languages found different things to work for different people