excessive/cpml

nil passed to isvector should return false

Opened this issue · 6 comments

When a nil is passed, it errors, "attempt to index v (a nil value)".

Do you think it should throw a meaningful error or just return false?

Well, a nil is not a vec3, so it should return false. Erring should be the choice of the caller.

it was this way intentionally, but in hindsight it makes more sense that it'd nil check by itself. I'll take care of it.

Don't know if you're planning on doing it this way or not, but I think it would be easiest to just add a simple check for truthiness at the beginning. I.e

function isvector(v)
    return v and -- ...
end

edit never mind, you have to do other type checking as well, so not really worth it to do that. It would be easier to just check if v is a table

@shakesoda I went ahead and fixed it via commit 112

thanks!