Re: Fortran 2003: abstract interfaces
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Thu, 31 Jan 2008 08:37:35 -0800
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
.
- References:
- Fortran 2003: abstract interfaces
- From: Arjen Markus
- Re: Fortran 2003: abstract interfaces
- From: Tobias Burnus
- Fortran 2003: abstract interfaces
- Prev by Date: Re: The concept of a record
- Next by Date: Re: computing Bernoulli numbers
- Previous by thread: Re: Fortran 2003: abstract interfaces
- Next by thread: computing Bernoulli numbers
- Index(es):
Relevant Pages
|