Uses
Posted Mar 31, 2012 5:44 UTC (Sat) by
Cyberax (
✭ supporter ✭, #52523)
In reply to:
Uses by cmccabe
Parent article:
Go version 1 released
So your code instead of:
if (is_set(ctx, 'debug_mode') && is_set(ctx,'show_log'))
// do_something();
Becomes:
(debug_mode, err1) = is_set(ctx, 'debug_mode')
if (err1) return err1;
(show_log, err2) = is_set(ctx, 'show_log')
if (err1) return err1;
if (debug_mode && show_log)
// do_something()
So a one-liner quickly turns into an unreadable ream of error-prone source code.
But let's go further. Suppose I have a lazy-loaded collection that exposes a Map interface. I.e.
map[string,string] m = make_lazy_map(...);
string a = m.get('hello')
The code that works with this map might not even know that it can return errors. What are you going to do in this case?
Exceptions are complex because they solve a complex task. And any attempt to solve it any other way leads to Yet Another Dumb Exception Framework, as Go show us.
(
Log in to post comments)