Xref: utzoo comp.arch:4031 comp.lang.misc:1309 Path: utzoo!mnetor!uunet!husc6!ncar!gatech!purdue!i.cc.purdue.edu!k.cc.purdue.edu!l.cc.purdue.edu!cik From: cik@l.cc.purdue.edu (Herman Rubin) Newsgroups: comp.arch,comp.lang.misc Subject: Re: FORTRAN Horror Message-ID: <721@l.cc.purdue.edu> Date: 24 Mar 88 11:18:03 GMT References: <24861@yale-celray.yale.UUCP> <1135@pembina.UUCP> <800@cresswell.quintus.UUCP> Organization: Purdue University Statistics Department Lines: 40 Summary: But it takes forever to run! In article <800@cresswell.quintus.UUCP>, ok@quintus.UUCP (Richard A. O'Keefe) writes: > In article <10037@steinmetz.steinmetz.ge.com>, davidsen@steinmetz.steinmetz.ge.com (William E. Davidsen Jr) writes: || The arithmetic if is one of the few good things in FORTRAN > ... || Of course I wouldn't suggest having it be implemented as goto's, but || some reasonable syntax, such as: || evaluate (fun(4,"test") < 22) || { < 0 action } || { equal action } || { > 0 action } > > What's wrong with > typedef enum {LESS = -1, EQUAL = 0, GREATER = 1} Order; > extern Order int_compare(int, int); > > switch (int_compare(fun(4,"test"), 22) { > case LESS: ...; break; > case EQUAL: ...; break; > case GREATER: ...; break; > } > No new syntax needed. Where something like this pays off is when > you are comparing strings or complicated records, and you don't > want to do it twice, but that is when you are defining your own > comparison function anyway. This is really a comp.lang.misc issue. This is only acceptable if you are comparing _long_ strings or complicated records; it is far too costly otherwise. On the machines of the 50's, from which the language gurus seem to have gotten their ideas, testing and branching were cheap relative to computation; I fear that will never be the case again. Subroutine calls are expensive; even though int_compare (and is the problem only restricted to integers?) is not cheap, the subroutine call is likely to be even more costly. Few implementations allow the user to force inline. The mind of the mathematician can conceive far more than the compiler can fathom. -- Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907 Phone: (317)494-6054 hrubin@l.cc.purdue.edu (ARPA or UUCP) or hrubin@purccvm.bitnet