Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is your opinion on what the default behavior of nil should be, fortunately, We can disagree and you can set a metatable that errors on nil, I will choose to do or not do that depending on the object.

assert() also exists for this very reason.

PS: there is a performance penalty between doing d["foo"] v d.foo, one expects an expression, the other does not. So it cannot be compiled. lua also errors on use of a nil value, d.foo() will error, d.foo + 3 will also error. So while it does "silently return a marker" it will crash on runtime.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: