News for hackers. Stuff that matters.
Re:LLVM Programmer’s Manual by hacker_9 on Friday July 22, 2016 @04:12AM (#12142333)
This is actually really interesting to me. I use C# for side projects and often write Debug.Assert everywhere to check things, but can't quite bring myself to throw exceptions for full blown errors. I just find they add a lot of bloat, and don't really help the problem, they are just a lazy catch all. But I have to say returning Error<TResult> is a really elegant way of dealing with the problem, I think I will have to start doing it this way.
Re:LLVM Programmer’s Manual by barrkel on Friday July 22, 2016 @06:22AM (#12142712)
Returning an error type, and, in the caller, propagating that return type further up, is isomorphic to exceptions, except it's a lot more busywork, a lot more code bloat, and a lot easier to get wrong.
Re:LLVM Programmer’s Manual by yoklov on Friday July 22, 2016 @11:11AM (#12144011)
It's also encoded in the return type of the function, so you get static type checking -- a property not present for exceptions.
Re:LLVM Programmer’s Manual by barrkel on Friday July 22, 2016 @03:26PM (#12146108)
You say that like it's desirable. I think Java's experience of checked exceptions shows that it's of very dubious benefit.
Re:LLVM Programmer’s Manual by perspectivep on Friday July 22, 2016 @10:31AM (#12143720)
And you have to remember to log the error at every level of the stack, otherwise you're left with an error code that has no context.