Path: utzoo!utgpu!watserv1!watmath!att!pacbell!pacbell.com!ucsd!sdd.hp.com!elroy.jpl.nasa.gov!ncar!midway!tank!stephen From: stephen@estragon.uchicago.edu (Stephen P Spackman) Newsgroups: comp.lang.c Subject: Re: TRUE and FALSE Message-ID: Date: 7 Sep 90 04:15:18 GMT References: <5398@harrier.ukc.ac.uk> <3686@goanna.cs.rmit.oz.au> <1990Sep6.113259.2109@ifi.uio.no> Sender: news@midway.uchicago.edu (News Administrator) Organization: University of Chicago CILS Lines: 47 In-Reply-To: jar@ifi.uio.no's message of 6 Sep 90 11:32:59 GMT To pick up on a couple of comments: In article <1990Sep6.113259.2109@ifi.uio.no> jar@ifi.uio.no (Jo Are Rosland) writes: Why can't I do this in C? The && and || operators are defined to return either 0 or 1. With the Lisp semantics I could write code like: return f() || g(); instead of: a = f(); if (a) return a; else return g(); This is useful eg. when f() and g() return pointers (maybe in some sort of search, where we only want to call the second function if the first one fails.) And I even think the first version reads better. The single most important case is, of course, when f() and g() return functions. You could code all of that ecchy high-level strategy-finding code in this style: return (f() || g())(x); And if THAT ain't clarity, I don't know what is. In article <1990Sep6.113259.2109@ifi.uio.no> jar@ifi.uio.no (Jo Are Rosland) writes: The is_true() macro is almost as useful as a macro you might write to return the numeric value of its argument, i.e.: a = value_of( b ) + value_of( c ); I'm in favour, though I'd like to see a prefix operator for this. There damn well ought to be an operator for extracting values from variables, so people don't confuse them with constants. And to encourage them to USE constants. (And it's been done in real languages, honest). stephen p spackman stephen@estragon.uchicago.edu 312.702.3982