From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 102b75,45b50f14dadfce5b X-Google-Attributes: gid102b75,public X-Google-Thread: 110292,45b50f14dadfce5b X-Google-Attributes: gid110292,public X-Google-Thread: 1164f8,45b50f14dadfce5b X-Google-Attributes: gid1164f8,public From: Craig Burley Subject: Re: Final kick at the "Merced Guessing Game" Date: 1997/10/13 Message-ID: #1/1 X-Deja-AN: 280194560 References: <61g30t$o2n@news-rocq.inria.fr> <343C34A7.B715A348@tonys.ecology.umn.edu> <3440F805.C98BB347@tonys.ecology.umn.edu> <61tfaa$9fr@sis.cambridge.arm.com> Organization: Cygnus Support Newsgroups: comp.sys.intel,comp.arch,comp.sys.dec Paul Rubin writes: > Craig Burley writes: > > > > IMPLICIT LOGICAL(A-Z) > > BOOL = F() .AND. (G() .OR. H()) > > > Is this C statement equivalent to the Fortran? > > bool = !(!f() | (!g() & !h())); > > Translation: sets bool to 1 (.true.) if f() is nonzero (.false.) > and g() or h() is nonzero; makes sure all the functions are called, > but they could be called in any order. No, forget about the int/bool distinction, that's not what I was getting at. The Fortran statement does not *mean* "[make] sure all the functions are called". That's why Fortran is "higher-level" in this case, because it offers a construct that cannot be expressed in C, whereas it does offer (verbose, but still clear) ways to specify the lower-level constructs C specifies. This example is probably not important in most cases when it comes to generating optimal code, but it does illustrate the concept, being discussed here, that higher-level constructs have important advantages over lower-level ones. And, Fortran offers many higher-level constructs (functions, boolean operators, multi-dimensional arrays, adjustable arrays, and so on) that are inexpressible in C. I think even C's pointers can be expressed in FORTRAN 77, using a translation method that would be quite painful to live with (and thus worthless as a language to write code in), but there *are* no translations of some common, and frequently used, Fortran constructs available in the C language. Fortunately, there are typically several choices of *implementations* of such constructs that are available in C, which is why products like f2c (which *converts*, rather than translates, FORTRAN 77 to K&R C) can exist. -- "Practice random senselessness and act kind of beautiful." James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu