Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!bbn.com!nic!chaos.cs.brandeis.edu!iad From: iad@chaos.cs.brandeis.edu (Ivan Derzhanski) Newsgroups: comp.lang.misc Subject: Re: Fortran vs. C for numerical work - expression notation Message-ID: <1990Dec11.051448.10742@chaos.cs.brandeis.edu> Date: 11 Dec 90 05:14:48 GMT References: <16798@csli.Stanford.EDU> <8339@lanl.gov> Organization: Brandeis University Lines: 95 In article <8339@lanl.gov> jlg@lanl.gov (Jim Giles) writes: >[...] some of Fortran's (more or less) >standard operators (exponentiation, normal arithmetic on Complex, >etc.) require prefix (function call) notation in C. This is an >impediment. You may choose to call it trivial, but it is still an >impediment. Yes, it is indeed. It is sort of strange that a language with 40 operators should make exponentiation a function. I always think of this as one of the bad things in C. It could have had 41 operators just as easily. ... or 42, or 43, for that matter... Look, it is fine to accomodate the preferences of the math-minded people by making operators operators and functions functions, but it is also hopeless. There simply are too many operators in mathematics. Let's suppose exponentiation must not be prefix; we'll write it "**". Now what about factorial? It is just as common an operation. And it must be postfix. You don't want to create an impediment, do you? (Don't forget what double factorials mean in maths. 4!! is not (4!)! = 24!. Do you expect that users will be willing to unlearn this?) Next, how about... And so on and so forth... If this were a serious issue, languages which allow you to define your own operators (such as Algol-68) would have more success among number- processing users. >[...] both languages (but C more than Fortran) >use standard mathematical symbols for non-standard purposes. The >equal sign in both languages is used for assignment, for example. >Again, this is an impediment. Again, C suffers from it worse than >Fortran. Could you please say why? I'm completely confused by this statement. How can one language suffer more than the other by a deviation from standard mathematics that they both share? >[...] both languages use non-standard symbols for >standard mathematical concepts. Fortran uses '.and.' for conjunction, >while C uses '&', for example (the standard symbol for conjunction is, >of course, '/\'). I think that C is still worse than Fortran here. Again, why? I have seen "&" in quite many logic books. (It is another story, of course, that for some reason "&" is bit-wise conjunction in C, while truth values are conjoined with "&&", which looks awful.) >To be sure, C uses '<' and '>' for comparison operators, but then >commits the error of the last paragraph by using these same symbols as >part of the shift operators. By the very same logic, Fortran commits an error by using "*" for multi- plication, because it already is a part on the exponentiation operator. You commit an error if you call a variable "I", because that's part of the name of the sine function. >These last two points (and the fact that C uses the whole ASCII >character set in peculiar ways) 1. Is it really the whole ASCII charset? Remind me the use of the dollar sign. And of the backquote. 2. What is wrong with using the whole ASCII charset? What is it there for anyway? 3. What are the unpeculiar ways of using it? How would you use (put here the name of your favourite peculiarly-used character) in an intuitive way? > tend to make many C programs look >like communications line noise - at least to most non-users of C. It doesn't take too much time for much of this noise to start to make sense. It depends on the good will of the programmer. The language hasn't been designed that wouldn't allow you to write unreadable code should you choose to. >This can't be held in C's favor in a discussion about closeness >to standard forms of notation. No, since both languages are hopelessly far from standard notation. You know how introductory books go: "Thou shalt not write `(-1)**K' as thou dost in maths" etc. etc. Again, speaking of standard notation (and given the fact that the ASCII charset is a natural limitation). How about admitting that the C "?:" operator makes C look much more like maths? Conditional expressions (written with a big "{") are an integral part of the usual mathematical notation. They are very naturally converted to "?:". Fortran has nothing similar, which is a serious impediment. -- Ivan A. Derzhanski iad@chaos.brandeis.edu Any clod can have the facts, MB 1766 / Brandeis University but having an opinion is an art. P.O.Box 9110 / Waltham, MA 02254-9110 / USA Charles McCabe