From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 110292,45b50f14dadfce5b X-Google-Attributes: gid110292,public X-Google-Thread: 1164f8,45b50f14dadfce5b X-Google-Attributes: gid1164f8,public X-Google-Thread: 102b75,45b50f14dadfce5b X-Google-Attributes: gid102b75,public From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) Subject: Re: Final kick at the "Merced Guessing Game" Date: 1997/10/20 Message-ID: <62eqtu$2ua$1@goanna.cs.rmit.edu.au>#1/1 X-Deja-AN: 281918775 References: Organization: Comp Sci, RMIT University, Melbourne, Australia. NNTP-Posting-User: ok Newsgroups: comp.sys.intel,comp.arch,comp.sys.dec pmontgom@cwi.nl (Peter L. Montgomery) writes: >Craig Burley writes: >>I don't see any rebuttal there. Care to explain what *low-level* >>constructs C is offering that Fortran doesn't offer, aside from >>pointers? > Nobody has been mentioning unsigned arithmetic. The machine I used as an undergraduate didn't _have_ unsigned arithmetic in any form, and nobody ever missed it. I mean this quite literally: the machine had _no_ instructions that could be used to do any kind of unsigned arithmetic directly. Bitwise operations, yes. I wonder how many people would "need" unsigned arithmetic if C didn't have it? > C has conditional compilation, which Fortran does not. This claim is a little extreme. It's not as if C conditional compilation were in any way integrated with the language, like SAIL or PL/I or Burroughs Algol or Lisp. (Lisp is clearly way ahead head, closely followed by SAIL. PL/I, and the Burroughs Algol imitation of its preprocessor, isn't _too_ far off, but C is way down near the M4 end of things.) There isn't any preprocessor in the Fortran 90 standard (I don't know about F95), but that has never stopped anyone who wanted to use conditional processing with Fortran. I used to use a structured Fortran preprocessor (now pointless) written in SNOBOL. Presto chango, extremely powerful conditional processing. Remember: #if sizeof (int) == 4 is not legal C. > Fortran leads C in its large intrinsic function library. >C9X will finally let one write a MAX function which evaluates its >arguments once only and use the INLINE keyword to get good code, My understanding is that C9X is likely to contain f{min,max}{f,,l} functions anyway. > Neither language has constructs for the following operations >(although some implementations make them available): > . Trailing zero count of nonzero binary number > (equal to highest power of 2 dividing the number) This may be a low-level construct, but a lot of machines have no direct support for it. It may be programmed as easily in Fortran as in C. > . Truncated base-2 logarithm of nonnegative integer, > with LOG2(0) = -1. [Or return the number of bits required > to hold the value, which is one more than its logarithm.] This may be a low-level construct, but a lot of machines have no direct support for it. It may be programmed as easily in Fortran as in C. > . Population count of nonnegative integer. This may be a low-level construct, but a lot of machines have no direct support for it. It may be programmed as easily in Fortran as in C. > . Upper half of (signed or unsigned) integer product. This may be a low-level construct, but some machines (sigh) have no direct support for it. Ultra-SPARC is one of them. Perhaps if C _had_ had this, Ultra-SPARC would have, but then, it hasn't got a mod instruction either. LIA-2 has MULLO and MULHI functions, and C9x is taking LIA seriously, so something of the sort may find its way into C. I wonder what they will do on an UltraSPARC? A Fortran binding for LIA-2 will also have to address this. > . Greatest common divisor (GCD) of two integers. This too is in LIA, so may be in C9x. A Fortran binding for LIA-2 will also have to address it. > . Floating point operations with explicit rounding, > such as ROUND_DOWN(a - ROUND_ZERO(b*c)) > to round the product b*c towards zero and > round the difference a - b*c towards -infinity. Very nice, but there are pre-IEC559 machines that are still of practical importance that have good Fortran systems, even C systems, and cannot easily support these operations. >All of these, except the GCD, have simple translations on the >latest DEC Alpha. A nice machine. >They have mathematical definitions >which do not refer to the target architecture, >except that we need the number of bits per datum to >define the upper half of an integer product. >The optimal translations vary widely >with the target architecture, and the first three constructs >have been discussed many times in this newsgroup, >yet the language designers decline to standardize the constructs. Not all of these constructs, and not all language designers. Lisp has your truncated base-2 logarithm, population count, and greatest common divisor. It doesn't need MULLO/MULHI. LIA-2 includes GCD, MULLO, and MULHI, and it is supposed to be "language-independent", in the sense that language standardisers will be expected to provide standard bindings to it. -- John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL. Richard A. O'Keefe; RMIT Comp.Sci; http://www.cs.rmit.edu.au/%7Eok