Go Programming talk [OT]

Adam Ruppe destructionator at gmail.com
Mon Jun 7 12:33:15 PDT 2010


On 6/7/10, Bill Baxter <wbaxter at gmail.com> wrote:
> Hmm, but I can actually understand your code.  :-(

The confusing part is probably cenforce, which is a little helper
function in the std.file module.

cenforce(condition, filename) is the same as

if( ! condition)
   throw new FileException(filename, __FILE__, __LINE__, GetLastError());

So the new read() does still have control statements, but they are
hidden in that helper function template so you don't have to repeat
them all over the main code.

Then, of course, the scope guards clean up on the event of those
exceptions, so you don't have to worry about the special error labels,
which is what allows the helper function to actually be useful!


More information about the Digitalmars-d mailing list