Re: Allocatable scalar components not allowed in derived types...
by Paul van Delst <Paul.vanDelst@[EMAIL PROTECTED]
>
Jul 23, 2008 at 05:19 PM
Rich Townsend wrote:
> Just out of curiosity, could anyone enlighten me why allocatable scalars
> aren't allowed in derived types (in F2003 or F95 + TR15581)? It strikes
> me as this could be a useful way of having a component that either has a
> well-defined value (ALLOCATED(foo%bar) == .TRUE.) or has no value
> (ALLOCATED(foo%bar) == .FALSE.).
Probably because what you want to use them for is a bad idea? :o)
What wrong with using an actual component that you explicitly set? E.g.
type mytype
logical :: bar = .false.
...other stuff
end type mytype
?
Why would you want to use an ALLOCATABLE component for simply checking
true/false? If
there is a good reason (which I doubt) what about,
type mytype
integer,allocatable :: bar(:)
...other stuff
end type mytype
.....
type(mytype) :: foo
You can still use that for your test:
if( allocated(foo%bar) ) then
....
end if
?
cheers,
paulv
p.s. Welcome back.