Re: Allocatable attribute on derived type components
- From: nospam@xxxxxxxxxxxxx (Richard E Maine)
- Date: Fri, 30 Jun 2006 13:19:09 -0700
gaurav <gauravgautam123@xxxxxxxxx> wrote:
since functionality of
allocatable component can be done with pointer component...
No, no, no! Or to quote a J3 member (about a point that he later lost on
:-), 1000 times no.
Functionality comprises more than memory layout. If you think that
memory layout is all that matters, then you are going to be puzzled
about an awful lot of things. Indeed, starting with Fortran 90, the
standard moves more towards abstracting things in ways that don't even
talk about memory layout.
Assignment works *VERY* differently with pointer components than with
allocatable ones. So does allocation and deallocation. I would take
almost the opposite viewpoint - that pointer and allocatable components
have almost nothing in common, except for the small detail that they
might have similar memory layouts.
See the many, many posts in the past from people who were confused about
how pointer components worked. Almost invariably, the reason that they
were confused is that they were using pointer components as a substitute
for allocatable ones (which weren't available until recently). Their
mindset was therefore one of thinking about these as allocatables. Well,
they don't work like one would expect an allocatable to sensibly work;
they work like you would expect pointers to work.
I'll defer details, as they are covered elsewhere, I'm short on time,
and this is getting overly long anyway.
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
.
- References:
- Allocatable attribute on derived type components
- From: gaurav
- Re: Allocatable attribute on derived type components
- From: Arjen Markus
- Re: Allocatable attribute on derived type components
- From: gaurav
- Allocatable attribute on derived type components
- Prev by Date: Re: EDITOR: Compaq Visual Fortran
- Next by Date: Re: question about using array intrinsic functions
- Previous by thread: Re: Allocatable attribute on derived type components
- Next by thread: [ANN] fUnit 0.1.3 - A Fortran Unit Testing Framework
- Index(es):
Relevant Pages
|