1. Checking for failures... A curiosity about good coding practises

Over the past few years I've been tinkering around with C mostly, and if I'm honest I probably spend more time thinking about how to write good code as opposed to actually making things :) (Fortunately I don't write code for a living but I do look for bugs!)

Having written some code in Euphoria many years ago and occasionally reading up on the new changes and trying a few test programs out, it occurred to me that many of the built-in routines that could fail in some way don't have any way to check for errors.

In particular, say for example you call puts() to output some data into a file. There doesn't appear to be a way to handle errors - what if the disk fills up or there is some other I/O error, for example?

Arguably this concern can be addressed by hooking into the WriteFile API on Win32 for example. I'm guessing it was done this way originally for simplicity and probably also because in the older versions having puts() return something would make it a function so you'd be obligated to assign the result to something.

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu