Re: Fortran 2003: abstract interfaces



Tobias Burnus <burnus@xxxxxxxx> wrote:

On Jan 31, 2:54 pm, Arjen Markus <arjen.mar...@xxxxxxxxxx> wrote:
abstract interface
subroutine dothis( ... )
end subroutine
end interface
This abstract interface is part of a typ definition.

Presumably you mean that it goes with the type definition in some sense,
perhaps being defined in the same module and being intended for use in
conjunction with the type. I don't recall that there is a way to have an
aabstract interface be literally part of a type definition.


How do I specify that a particular routine implements the interface
"dothis"?
Is that via the procedure statement:
procedure(dothis) :: do_it_this_way

This works.

Yep.

Or via:
interface dothis
module procedure do_it_this_way
end interface
Or how?

This does not work since (a) do_it_this_way is not a module procedure
and "interface dothis" clashes with "subroutine dothis" in the
abstract interface.

The part about not beng a module procedure is easily resolved by
removing the keyword "module" from the statement. Insomuch as you have
to have f2003 to have an abstract interface in the first place, any
compiler that supports an abstract interface will certainly support
removal of the "module" keyword. Removing the "module" keyword is a
simple enhancement that I'd expect f95 compilers to add long before they
do more esoteric things like abstract interfaces.

In my personal opinion, the use of the "module" keyword in thsi context
is deprecated in f2003. The form with "module" was a mistake in the
first place and caused quite a bit of awkwardness in some cases.

This doesn't address the more fundamental clash that Arjen mentions. No
you can't do things this way because it is using the name dothis for two
different things (perhaps unintentionally, but that's what it is).

The form of interface block that starts with

interface dothis

is for specifying that do this is a generic procedure, with specific
procedures as specified in the block. You can't have dothis be both a
generic procedure and an abstract interface. Besides, even if that
comflict were allowed, this interface block would not mean what you
intend. It would specify that do_it_this_way was a specific in the
generic, but it would say nothing about the interface of do_it_this_way.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.



Relevant Pages

  • Re: For the AdaOS folks
    ... >> implementation could be a module, no problem, but all system objects, ... >> carrier, yes, as an interface no. ... Develop a general API to leave flexibility in the hands of the designer ... abuses, and secondly, we could define somewhere an abstract interface to be ...
    (comp.lang.ada)
  • Re: For the AdaOS folks
    ... gone beyond the registry in proposed solutions yet. ... > abuses, and secondly, we could define somewhere an abstract interface to be ... Yes of course - ie. it must support the Ada RTL, ...
    (comp.lang.ada)
  • Re: Fortran 2003
    ... interface, abstract ... I don't like the "abstract" being ended by an "end interface" (shoulda been "end abstract interface" at least. ... subroutine print_me (arg, lun) ...
    (comp.lang.fortran)
  • Re: Fortran 2003: abstract interfaces
    ... subroutine dothis(... ... This abstract interface is part of a typ definition. ... This does not work since do_it_this_way is not a module procedure ...
    (comp.lang.fortran)
  • Re: Fortran 2003: abstract interfaces
    ... I'm suspicious that you are confusing an interface and an interface ... particular procedure has a particular abstract interface, ... An interface block can define one or more interfaces. ... interface body specifies what specifics are included in the generic. ...
    (comp.lang.fortran)