From malcolm@red.nag.co.uk  Thu Jul 18 17:04:32 1996
Received: from red.nag.co.uk ([192.156.217.2]) by dkuug.dk (8.6.12/8.6.12) with SMTP id RAA12778 for <sc22wg5@dkuug.dk>; Thu, 18 Jul 1996 17:04:29 +0200
Received: by red.nag.co.uk (920330.SGI/920502.SGI)
	for sc22wg5@dkuug.dk id AA03653; Thu, 18 Jul 96 15:51:11 +0100
Date: Thu, 18 Jul 96 15:51:11 +0100
From: malcolm@red.nag.co.uk (Malcolm Cohen)
Message-Id: <9607181451.AA03653@red.nag.co.uk>
To: sc22wg5@dkuug.dk
Subject: Problems with proposed change to 1539-2

There are a couple of problems with the proposed revision of the example module
for ISO_VARYING_STRING, in paper N1183.

First off, a minor problem:

Given
  USE ISO_VARYING_STRING
  TYPE(VARYING_STRING) A

Although it is legal (by the normative text) to say:
  A = A

It causes a problem with the new module, because it deallocates the storage
before using it.

Secondly, an extremely serious problem:

Given
  USE ISO_VARYING_STRING
  TYPE MYTYPE
    TYPE(VARYING_STRING) VALUE
  END TYPE
  TYPE(MYTYPE) A,B

The assignment
   A = B
will invoke ***POINTER ASSIGNMENT*** on the components, not the one defined by
the module.

This is ok with the old string module in 1539-2, because it never deallocates
or overwrites the hidden pointer ("chars") arrays.

But with the proposed module in N1183, after the above assignment, the
statement
   B%VALUE = "Goodbye"
will deallocate the storage pointed to by the hidden pointer component of
A%VALUE, effectively destroying the VARYING_STRING component of A.

There is certainly no obvious way of getting around this problem, so the N1183
module is not a conforming implementation of ISO_VARYING_STRING.

Thus IMO the appropriate action to be taken is not to revise the string module
for Fortran 95, but to wait until sufficient facilities have been added to
the language to make a more efficient solution than the one we already have
possible.  Some possible solutions would be allocatable components with nice
assignment, a special "defined_assignment" attribute for derived types to
make them use the defined assignment even when they are components, or some
clever new OO stuff.

Cheers,
-- 
 ...........................Malcolm Cohen, NAG Ltd., Oxford, U.K.
                           (malcolm@nag.co.uk)


