Re: avoiding writing an interface blocks



On Tue, 19 Dec 2006 21:59:56 +0000 (UTC), glen herrmannsfeldt
<gah@xxxxxxxxxxxxxxxxxxxxxxx> wrote:

Richard E Maine <nospam@xxxxxxxxxxxxx> wrote:

That's what is called *NOT* having an explicit interface. As the OP
correctly noted, that's not allowed in this case. His usage has an
array-valued function result. You cannot declare that without an
explicit interface. There wouldn't be any point in just declaring the
type; the reason this needs an explicit interface is because of the
arrayness, so you have to declare that or the purpose wouldn't be
achieved.

Yes. Some people consider the return value as separate from
the arguments, others as an additional INTENT(OUT) argument.
(Implementations likely work both ways.)

In C, one can specify the return type, even if it is, for
example, an array, and not specify the argument types. There
are cases in C where it is required to specify the argument types,
and cases where it isn't.

Yes, in C you can declare only the return type (oldstyle/K&R1) or also
all the parameter=dummy types (prototype/ANSI). And in general C type
does include array shape, or rather size since only 1D and 0-origin
are (directly) supported. But no, C functions cannot return an array
type, period, with any kind of declaration. (They can return a struct
containing an array, in much the way F9X cannot have array of pointer
but can have array of derived-type containing pointer.)

In principle in C89+ like F90+ you must use a newstyle/prototype
declaration if you use 'new' features in the call signature, but the
breakdown as to what is new differs. C-type pointers, including to
functions, already existed in K&R1C and work in C89 oldstyle, and as
above returned arrays don't exist in either old or new. (Array
_parameters_ =dummies in both old and new are just syntactic sugar for
pointers, which as above are the same old and new.) (Neither does
anything resembling allocatable.)

'Narrow' (by-value) argument types, namely char and short (signed and
unsigned variants) and float (single), formally require a prototype
declaration, and so do variadic argument lists. But in practice most C
implementations use calling sequences that actually work for narrow
types, and many (including x86) use ones that are compatible for
varargs vs fixedargs, so many C programmers don't learn this, and it's
a FAQ/FGA on clc. (Sound familiar?) Whereas I don't see much chance a
reasonable Ftn processor can make data-pointer or allocatable dummies
or returns or array returns work compatibly with old/implicit calls.
(To be safe I don't say impossible and it's certainly not prohibited.)
I'd guess it probably is (often?) possible to make procedure pointers
compatible with oldstyle EXTERNAL dummies, but why bother?

- David.Thompson1 at worldnet.att.net
.



Relevant Pages

  • Re: Banks and economy
    ... byte pointers? ... pointer type - which I think is correct for "arrays", and the cptr pointer ... "Without a later declaration, there will be an implicit initialisation ... called the element type.Array ...
    (alt.lang.asm)
  • Re: a history question
    ... >> arrays of pointers. ... > (especially if it can be circumvented easily with a derived type)? ... There is simply no syntax for declaring an array of pointers. ... This is the declaration of a pointer to an array. ...
    (comp.lang.fortran)
  • Re: Need help on PHP for MPE/ix
    ... If one item is an array, it must be declared as such in the list ... So, please show us the declaration of the record buffer, and its ... Of Pavan Kumar Rati ... Need help on PHP for MPE/ix ...
    (comp.sys.hp.mpe)
  • Re: Difference between C and advanced C
    ... static and type qualifiers in parameter array declarators ... trailing comma allowed in enum declaration ... additional predefined macro names ... additional strftime conversion specifiers ...
    (comp.lang.c)
  • Re: Does the order of declarations matter?
    ... > subroutine sub ... > Or must the declaration for N appear before the declaration ... parameter or array bound shall be specified in a prior ...
    (comp.lang.fortran)