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

The situation of multiple falsy values is more like Javascript than Common Lisp.

If you have only one false value, it means that this test

  if (str)
can mean "we have a string object here". If we make str take on the false value, such as nil, then that is not a string.

If an empty string is false, then we cannot use this test.

An empty string being false encourages the poor practice of using empty strings to mean "there is no value here".

You might as well code in Bash.



> An empty string being false encourages the poor practice of using empty strings to mean "there is no value here".

That is not bad practice, as I said before, you almost always want to only process non-empty Strings, but sometimes an empty String comes in from user input or whatever and you either have to check it everywhere like in Java, or in Groovy that is just the default... you can still do 'if (str != null)' to be more explicit, but in my experience that is almost never what you want. Bad practice is making the more usual case look more unusual.

Also, it's nothing like JS because in JS empty lists and maps are `true`! The commonality with Common Lisp is exactly that "not being empty" is what the concept of true represents.




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

Search: