Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ubc-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!ihnp4!alberta!ubc-vision!ubc-ean!ubc-cs!ludemann From: ludemann@ubc-cs.UUCP (Peter Ludemann) Newsgroups: net.lang.c Subject: Re: Use of expression values in C Message-ID: <1158@ubc-cs.UUCP> Date: Sat, 13-Jul-85 14:57:44 EDT Article-I.D.: ubc-cs.1158 Posted: Sat Jul 13 14:57:44 1985 Date-Received: Wed, 17-Jul-85 04:22:16 EDT References: <474@crystal.UUCP> <397@umcp-cs.UUCP> <721@wlcrjs.UUCP> <5755@utzoo.UUCP> <685@lll-crg.ARPA> <5764@utzoo.UUCP> Reply-To: ludemann@ubc-cs.UUCP (Peter Ludemann) Organization: UBC Department of Computer Science, Vancouver, B.C., Canada Lines: 8 Summary: For those who think "if ((foo=fopen(filename,"r"))==NULL) { ... }" is hard to understand, why not create a macro to handle this: #define opentest(filename,mode,ptr) ((ptr=fopen(filename,mode)==NULL) and then you can write "if (opentest(filename, "r", foo)) { ... }" To understand this, you just have to refer to the usual 10 pages of inscrutable #defines which come with the program -). But I do think that the macro approach is slightly more readable. It almost looks like a subroutine call with a "var" parameter.