News for hackers. Stuff that matters.
Re:Don't return null; use a tail call by ufo on Tuesday January 10, 2012 @07:39AM (#3446716)
The important thing here is not that passing onOK and onError callbacks is a good idea. The real issue is that NULL pointers are the most dangerous thing invented in the 20th century and should be avoided like the plague.

From an [expression problem](http://c2.com/cgi/wiki?ExpressionProblem) point of view using a discriminated union (in the same spirit as returning null but safer, since you can you peek at the value after doing a null check) would probably be just fine anyway. You still get to avoid the danger of NULL pointers but you still get a real value to work with (unlike the callback case that allways immediately splits it) so you can store it, pass it around, etc.

By the way, astute readers might have recognized all that callback passing as just the [visitor pattern](https://en.wikipedia.org/wiki/Visitor_pattern) in disguise.

Re:Don't return null; use a tail call by VMG on Tuesday January 10, 2012 @08:44AM (#3446898)
> The real issue is that NULL pointers are the most dangerous thing invented in the 20th century

Not sure if serious

Re:Don't return null; use a tail call by ufo on Tuesday January 10, 2012 @10:48AM (#3447313)
I am somewhat serious about this. Tony Hoare even called them his "Billion Dollar mistake" in a talk he gave a while ago (http://www.infoq.com/presentations/Null-References-The-Billi...)
Re:Don't return null; use a tail call by barrybe on Tuesday January 10, 2012 @02:02PM (#3448420)
That talk gets quoted pretty often, but it's a bit silly for Hoare to take all the blame/credit. Null references were discovered, not invented. They are so easy (from the point of view of someone implementing a non-functional language) that they were inevitable.