Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Fortran > Re: Derived typ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 26 Topic 8212 of 8767
Post > Topic >>

Re: Derived types and allocatable

by "James Giles" <jamesgiles@[EMAIL PROTECTED] > May 14, 2008 at 07:30 PM

Jan Vorbrüggen wrote:
>> I too wish they had given the same meaning to all four variants.
>
> I don't think that can be done. On the LHS, A(:) is a slice, and
> therefore must be allocated and defineable for the assignment to have
> a meaning at all. Think about it - what if I wrote:
>
> A(::2) = B
>
> What semantics would you ascribe to this assignment in case A is not
> allocated in a conformable way?

Actaully A(:) is easily recognizable as a slice that corresponds
to the whole array.  A(::2) is easily recognizable as a slice
that does *not* mean the whole array.  What I wanted was that
if the left-hand side is not subscripted (the whole array) or is
subscripted with only colon (:) in each subscript position,
the meaning should be the same.  It's an easily recognizable
syntactic form.  If the subscripts in each dimension *aren't*
merely colon (:), then the thing should follow the existing
rule for slices (even if the bounds expressions on the
subscript triplets turn out to refer to the whole aray).

Hence:

   real, allocatable :: x(:)
   ...
   allocate(x(100))
   ...

   x(1:100) = expr

This should require conformability even though the subscript
turns out to refer to the whole array.

   x = expr
   x(:) = expr

The above two could mean the same thing, even if that means
reallocation.

In fact, what would really be useful is a the following as
well as the above:

   x(5:) = expr

This reallocates if necessary and the new low-bound of the
array is 5.

   x(:10) = expr

This reallocates if necessary and the new upper bound of the
array is 10.  I suppose these last two would be too error prone
though and should not be allowed.  :-(


-- 
J. Giles

"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies."   --  C. A. R. Hoare
 




 26 Posts in Topic:
Derived types and allocatable
Gib Bogle <g.bogle@[EM  2008-05-06 16:01:28 
Re: Derived types and allocatable
Gib Bogle <g.bogle@[EM  2008-05-06 18:09:36 
Re: Derived types and allocatable
"James Van Buskirk&q  2008-05-06 00:41:26 
Re: Derived types and allocatable
Steven Correll <steven  2008-05-06 07:08:11 
Re: Derived types and allocatable
"James Giles" &  2008-05-11 00:26:34 
Re: Derived types and allocatable
=?ISO-8859-15?Q?Jan_Vorbr  2008-05-14 12:07:46 
Re: Derived types and allocatable
"James Giles" &  2008-05-14 19:30:39 
Re: Derived types and allocatable
glen herrmannsfeldt <g  2008-05-14 12:39:38 
Re: Derived types and allocatable
"James Giles" &  2008-05-14 20:49:59 
Re: Derived types and allocatable
glen herrmannsfeldt <g  2008-05-14 13:27:46 
Re: Derived types and allocatable
"James Giles" &  2008-05-14 21:40:48 
Re: Derived types and allocatable
=?ISO-8859-15?Q?Jan_Vorbr  2008-05-15 11:14:13 
Re: Derived types and allocatable
"James Van Buskirk&q  2008-05-14 11:03:21 
Re: Derived types and allocatable
"James Giles" &  2008-05-14 19:37:02 
Re: Derived types and allocatable
"Kurt Kallblad"  2008-05-07 07:56:49 
Re: Derived types and allocatable
nospam@[EMAIL PROTECTED]   2008-05-07 00:15:43 
Re: Derived types and allocatable
Gib Bogle <bogle@[EMAI  2008-05-08 08:35:27 
Re: Derived types and allocatable
Damian <damian@[EMAIL   2008-05-07 12:03:34 
Re: Derived types and allocatable
Steve Lionel <Steve.Li  2008-05-07 15:33:13 
Re: Derived types and allocatable
Damian <damian@[EMAIL   2008-05-08 09:05:09 
Re: Derived types and allocatable
Steve Lionel <Steve.Li  2008-05-08 12:52:00 
Re: Derived types and allocatable
Damian <damian@[EMAIL   2008-05-08 19:56:55 
Re: Derived types and allocatable
Steve Lionel <Steve.Li  2008-05-09 14:11:34 
Re: Derived types and allocatable
Damian <damian@[EMAIL   2008-05-09 12:15:07 
Re: Derived types and allocatable
"James Van Buskirk&q  2008-05-06 00:11:29 
Re: Derived types and allocatable
Gib Bogle <g.bogle@[EM  2008-05-06 18:39:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 12:52:55 CDT 2008.