Hacker News new | past | comments | ask | show | jobs | submit login

I dont think there is something wrong with that once you think about what is a Null Element (or identity) in a group that is represented by a set of elements and a function:

Integer, + => 0

Float, + => 0.0

Array, add => []

Hash, merge => {}

and so on.

I think maybe we can debate the operations/functions, but they make sense. For Integer in some ways you can define almost all other operations that you commonly use based on the addition.

So while nil is an object when trying to find a representation in other group I find it logical or expected.

Also Ruby will not automatically try to coerce nil when not asked to do so

like for example 0 + nil will throw an error.




Integers support both addition and multiplication and taking maximum and minimums, and a few other semi-group operations. Do you want to define different Null elements for all of them?


No, I don't want to define a representation for Null to all possible combinations of a set and a function/operation. That can be done by each developer if they see it fit and of the operations they want to have this.

But, for me, it makes sense to have a default representation for Null (that it is not automatically coerced—only if the developer explicitly asks for it) for one of the most common operations in that specific group.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: