Re: double confusion



Gordon Sande wrote:
On 2006-07-17 15:38:52 -0300, glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx> said:

(snip)

Doesn't IMPLICIT have the same scoping problem as other declarations?

The OP thought that a declaration of the following function would
be used by the preceding program because they were in the same file.
If there had been an IMPLICIT NONE in the main there would have been
diagnostics about the missing declaration of the function.

OK, but even better would be IMPLICIT NONE for each subroutine
and function...

The IMPLICIT NONE would have made it rather explicit that there was
no declaration of the double precision function in the scope of the
main program. The problem was to purge the scope of default declarations
so the OP would know what declarations the compiler was applying. The
problem was the implicit defaults and the F77 linking rules allowing
a program into execution where it did not work correctly.

I believe some languages will carry declarations forward, but not
backward. For the case in question, I believe C would give an error
when it found the function definition that didn't agree with the implicit declaration in main. If the function came first, that would
declare its return type. As we know, Fortran doesn't do that.

The OP had the "look and feel" of someone who expected the C rules
on file scope to apply to Fortran separate compilations. So the
question was how to make it easily explicit that something was
missing. Undoubtedly some poor overworked soldier who had been told
"You're a programmer. Deal with this."

I think this one confused me a while when I started learning C, applying
the Fortran rules to C.

(snip)

-- glen

.



Relevant Pages

  • Re: Symbols in function return specifiers
    ... I hate that style of function declaration, ... prefix interpreted in the IMPLICIT context of the function? ... You can't generalize special-case rules as though they were general ... expression is typed by the implicit typing rules, ...
    (comp.lang.fortran)
  • Re: NAG, Sun, Compaq possible f95 bug
    ... when IMPLICIT NONE is in effect in the enclosing ... > scoping unit, it would be impossible to use such variables. ... declaration is not actually in the scope that it applies to. ...
    (comp.lang.fortran)
  • Re: Origin and History of Dot Syntax
    ... There is no such thing as an "implicit ... informally but it is not terminology used in the language definition, ... p is a const pointer to something. ... I don't remember seeing a proposal of how a more conventional declaration ...
    (comp.lang.c)
  • Re: Symbols in function return specifiers
    ... junk if the standard says so. ... prefix interpreted in the IMPLICIT context of the function? ... parameters, if any, specified by a previous declaration in the same ... expression is typed by the implicit typing rules, ...
    (comp.lang.fortran)
  • Re: Proposal: NOEXTERNAL
    ... Require an explicit external declaration for implicit interfaces. ...
    (comp.lang.fortran)