Path: utzoo!attcan!uunet!husc6!uwvax!vanvleck!uwmcsd1!bbn!rochester!pt.cs.cmu.edu!speech2.cs.cmu.edu!jgk From: jgk@speech2.cs.cmu.edu (Joe Keane) Newsgroups: comp.arch Subject: Re: Branch Delay Annullment Message-ID: <1995@pt.cs.cmu.edu> Date: 19 Jun 88 21:43:03 GMT References: <22065@amdcad.AMD.COM> <12211@apple.Apple.COM> <27527@pyramid.pyramid.com> <12300@apple.Apple.COM> <4053@cbmvax.UUCP> Sender: netnews@pt.cs.cmu.edu Organization: Carnegie Mellon Lines: 29 In article <4053@cbmvax.UUCP> jesup@cbmvax.UUCP (Randell Jesup) writes: > I don't know about you, but I tend to write code that looks more >like: > if (!error) { > ... > } [else { ... }] > > Especially useful when doing resource allocations, like "if (!(ptr = >(struct ptr *) malloc(xyzzy))) { use ptr } else { return error }". I think that's less common, especially with multiple errors. A lot of my code looks like: if ((... = open (...)) < 0) quit (...); if (!(... = fopen (...))) quit (...); if (!(... = malloc (...))) quit (...); if ((... = read (...)) < 0) quit (...); if (fscanf (...) != 1) quit (...); ... It'd be nice if the compiler knew quit (same as `fprintf (stderr, ...); exit (...);') is a `dead' function, so it knows the branch is usually taken. --Joe