Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!wuarchive!wums2!bethge From: bethge@wums.wustl.edu Newsgroups: comp.lang.fortran Subject: Re: Fortran functions Message-ID: <1452.25c8b994@wums.wustl.edu> Date: 2 Feb 90 04:35:00 GMT References: <1990Jan30.191039.12165@siia.mv.com> Distribution: na Lines: 33 In article <1990Jan30.191039.12165@siia.mv.com>, wje@siia.mv.com (Bill Ezell) writes: > character*5 foo > character*5 ans > ans = foo(arg) > where foo is a function, not in the same file. Foo is not declared external. > ... how does [the compiler] know that the use of foo is a function call, > and not a subscript operation? Simple. If FOO has not previously been declared as an array, then FOO() cannot be a subscript operation, so it must be a function call. The "CHARACTER*5 FOO" is *not* an array declaration, because in Fortran a character string is *not* simply an array of characters, but is rather a distinct type of object. (Fortran is IMHO superior to several other popular languages in this respect.) This also answers your other question: > ... is there any difference between: > character*5 var > character var*5 > character var(5) The first two are identical, and are character strings of length 5. The third is an array of characters (actually, of character strings of length 1), with dimension 5. It is *not* the same. If a character string were an array, it could not be returned as a function value, right? _______________________________________________________________________ Paul H. Bethge bethge@wums.wustl.edu Washington University, St. Louis bethge@wums.bitnet