From owner-sc22wg5+sc22wg5-dom8=www.open-std.org@open-std.org  Fri May 17 05:09:28 2013
Return-Path: <owner-sc22wg5+sc22wg5-dom8=www.open-std.org@open-std.org>
X-Original-To: sc22wg5-dom8
Delivered-To: sc22wg5-dom8@www.open-std.org
Received: by www.open-std.org (Postfix, from userid 521)
	id DBE05356953; Fri, 17 May 2013 05:09:27 +0200 (CEST)
Delivered-To: sc22wg5@open-std.org
Received: from mail.jpl.nasa.gov (smtp.jpl.nasa.gov [128.149.139.109])
	by www.open-std.org (Postfix) with ESMTP id AE32F3568E2
	for <sc22wg5@open-std.org>; Fri, 17 May 2013 05:09:11 +0200 (CEST)
Received: from [137.79.7.57] (math.jpl.nasa.gov [137.79.7.57])
	by smtp.jpl.nasa.gov (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r4H398J2000938
	(using TLSv1/SSLv3 with cipher DHE-RSA-AES256-SHA (256 bits) verified NO)
	for <sc22wg5@open-std.org>; Thu, 16 May 2013 20:09:09 -0700
Subject: A colleague has asked me for this
From: Van Snyder <Van.Snyder@jpl.nasa.gov>
Reply-To: Van.Snyder@jpl.nasa.gov
To: sc22wg5 <sc22wg5@open-std.org>
Content-Type: multipart/mixed; boundary="=-PCOrp1YL2KN8+9F4cnLf"
Organization: Yes
Date: Thu, 16 May 2013 20:09:08 -0700
Message-ID: <1368760148.26528.501.camel@math.jpl.nasa.gov>
Mime-Version: 1.0
X-Mailer: Evolution 2.28.3 (2.28.3-30.el6) 
X-Source-Sender: Van.Snyder@jpl.nasa.gov
X-AUTH: Authorized
Sender: owner-sc22wg5@open-std.org
Precedence: bulk


--=-PCOrp1YL2KN8+9F4cnLf
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit

A colleague has asked me to propose the attached project.

It is a minor but non-trivial project that appears not to comport with
the Markham resolutions.  As such, I do not expect it to be added to the
work plan, but I shall submit the paper to the J3 archive, for the
record.

-- 
Van Snyder                    |  What fraction of Americans believe 
Van.Snyder@jpl.nasa.gov       |  Wrestling is real and NASA is fake?
Any alleged opinions are my own and have not been approved or
disapproved by JPL, CalTech, NASA, the President, or anybody else.

--=-PCOrp1YL2KN8+9F4cnLf
Content-Disposition: attachment; filename="201-wvs-004.txt"
Content-Type: text/plain; name="201-wvs-004.txt"; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit

                                                               J3/13-xxx
From:    Van Snyder
To:      J3
Date:    2013 May 16
Subject: Reference-counted pointer targets

Title: Reference-counted pointer targets

Submitted by: Van Snyder

Status: For consideration

Basic functionality: Define a class of pointers whose targets include
reference counts.  When and only when the reference count is decreased
to zero, the target is deallocated.

Rationale: It is difficult for users to develop and deploy a
reference-counted pointer target system.  It must be based upon derived
types, and separate versions of procedures for allocation, deallocation,
pointer assignment and nullification are needed for each type, kind, and
rank of the value component.  When developed and deployed, its use is
cumbersome, especially in existing programs that are to be revised to
exploit the system, since allocation, deallocation, pointer assignment,
and nullification must be replaced by subroutine calls.  To maintain
counts accurately, if a nonlocal pointer might be associated with the
same target as a local pointer, care must be taken that the local
pointer is nullified before the procedure in which it is declared
completes execution.  It would be better to require all such "pointers"
and their targets to be derived-type objects with a private pointer
component that represents the association, but there is no mechanism to
prevent pointer assignment for specified types.  An intrinsic solution
is therefore desirable.

Estimated impact: Minor

Detailed specification: Add an attribute to data pointers, say COUNTED
or CONTROLLED, that indicates their targets have reference counters.

A subobject of a target of a pointer that has this attribute does not
have the attribute.

The initial association status of such a pointer is disassociated, not
undefined; this does not need to be specified by initialization or
default initialization.

When such a pointer is the allocate-object in an ALLOCATE statement,
before the allocation, if the pointer has a target, the target's
reference count is decreased by one, and the target is deallocated if
the reference count becomes zero.  After allocation, the target's
reference count is set to one.

In pointer assignment, either explicitly by a pointer assignment
statement or implicitly by intrinsic assignment, either both the pointer
object and data target shall have the attribute, or neither shall. 
Thereby, one cannot associate a pointer with this attribute with a
target that has no counter, and one cannot associate a target that has a
counter with a pointer upon which actions do not respect or control the
value of the counter.  During pointer assignment, before assignment
takes place, if the pointer object is associated with a target, the
target's reference count is decreased by one.  After assignment, if the
pointer object has a target, the target's reference count is increased
by one.

In a NULLIFY statement, if the pointer has a target, its reference count
is decreased by one, and the target is deallocated if the reference
count becomes zero.

When such a pointer is the deallocate object in a DEALLOCATE statement,
the target's reference count is decreased by one, and then the target is
deallocated if and only if its reference count is decreased to zero.

When a procedure completes execution, local pointers, other than dummy
arguments, that have this attribute are nullified, as if by a NULLIFY
statement, rather than becoming undefined.

A consequence of these definitions is that, like allocatable variables,
a pointer with this attribute never has undefined association status.

--=-PCOrp1YL2KN8+9F4cnLf--

