Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: Re: Precedent for use of = Message-ID: <2306@umcp-cs.UUCP> Date: Wed, 9-Jul-86 00:50:15 EDT Article-I.D.: umcp-cs.2306 Posted: Wed Jul 9 00:50:15 1986 Date-Received: Fri, 11-Jul-86 04:46:44 EDT References: <4824@sun.uucp> <499@cbmvax.cbmvax.cbm.UUCP> <6056@sri-spam.ARPA> Reply-To: chris@maryland.UUCP (Chris Torek) Organization: University of Maryland, Dept. of Computer Sci. Lines: 35 In article <6056@sri-spam.ARPA> argv@sri-spam.UUCP (AAAARRRRGGGGv) writes: >this construct ... [if (lvalue = rvalue) { ...] is quite common in C, >altho good programmers comment that they know what they're doing here... >for example, my favorite: > >main(argc, argv) >char **argv; >{ > char *prog_name, *rindex(); > > if (prog_name = rindex(*argv, '/')) /* find last '/' in argv[0] */ > prog_name++; /* set prog_name to string following last '/' */ > else prog_name = *argv; /* program was exec-ed from same dir or in PATH */ > /* etc... */ I have come to favour if ((prog_name = rindex(*argv, '/')) != NULL) ... One of these years I will get around to installing Arthur Olson's lint code that gripes about assignments in conditional contexts. Adding the `!= 0' is not difficult and demonstrates your `true intention' quite well. >I would say that C was designed more robustly simply because you can >do the above [if (v = e)] whereas PASCAL won't let you. I think the proper word here is `orthogonal'. Actually, I have a feeling there is an even better word (no not *that* word :-) ), but I cannot recall it now. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu