April, 2005

  • mgrier's WebLog

    Always check your return codes?

    • 3 Comments
    Is there a bug here? int do_work(char *psz) { some_type *p = NULL; int t; if ((t = foo(&p, psz)) != 0) return t; if ((t = bar(p)) != 0) return t; if ((t = baz(p)) != 0) return t; return 0; // success } Let's be clear that this is ambiguous....
  • mgrier's WebLog

    Side-effects: a more useful definition

    • 3 Comments
    A typical CS-ish definition of whether a function has a side effect is whether the function modifies any globally visible state during its execution. e.g. this function is side-effect free: int add(int x, int y) { return x + y; } And this function...
  • mgrier's WebLog

    Function transactionality

    • 1 Comments
    A topic that comes up repeatedly in designing function is what a coworker of mine calls "transactionality". Since I have a little database background, I think that this is an abuse of the term but let's go with it for a while. Function transactionality...
  • mgrier's WebLog

    Errors and a simple invariant

    • 1 Comments
    Before addressing the problems with close_resource(), I want to explore another avenue which is invariant restoration. Let's amend the little function some more. I'm trying to stay away from Windows concepts but I need to update a global counter in...
  • mgrier's WebLog

    Future examples - standards, conventions

    • 0 Comments
    I'm going to start blogging some more and I just wanted to be explicit, as Raymond is, about the coding style I am going to use for my purposes. I have several types of issues I want to use my soapbox to discuss and elicit feedback. I'm going to...
Page 1 of 1 (5 items)