From j.l.schonfelder@liverpool.ac.uk  Tue Jun  1 12:52:02 1999
Received: from mailhub2.liv.ac.uk (mailhub2.liv.ac.uk [138.253.100.95])
	by dkuug.dk (8.9.2/8.9.2) with ESMTP id MAA00689
	for <SC22WG5@dkuug.dk>; Tue, 1 Jun 1999 12:52:02 +0200 (CEST)
	(envelope-from j.l.schonfelder@liverpool.ac.uk)
Received: from pcmail2.liv.ac.uk ([138.253.252.15])
	by mailhub2.liv.ac.uk with esmtp (Exim 1.92 #1)
	for SC22WG5@dkuug.dk
	id 10om8p-0007bE-00; Tue, 1 Jun 1999 11:51:31 +0100
Received: from [138.253.102.118] (helo=pc102118.liv.ac.uk)
	by pcmail2.liv.ac.uk with smtp (Exim 1.92 #1)
	for SC22WG5@dkuug.dk
	id 10om8o-0002PR-00; Tue, 1 Jun 1999 11:51:30 +0100
From: Lawrie Schonfelder <j.l.schonfelder@liverpool.ac.uk>
Reply-To: j.l.schonfelder@liverpool.ac.uk
To: SC22/WG5 members <SC22WG5@dkuug.dk>
Subject: (x3j3.1999-150) Re: (SC22WG5.1603) F95, String Module and problems due to  Language deficiencies
In-Reply-To: <3.0.1.32.19990528122806.00e428c8@postoffice.worldnet.att.net>
Message-ID: <SIMEON.9906011130.A@pc102118.liverpool.ac.uk>
Date: Tue, 1 Jun 1999 11:51:30 +0100 (British Summer Time)
Priority: NORMAL
X-Mailer: Simeon for Win32 Version 4.1.5 Build (43)
X-Authentication: IMSP
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII


On Fri, 28 May 1999 12:28:06 -0500 Dick Hendrickson 
<dick.hendrickson@att.net> wrote:

> At 05:38 PM 5/28/99 +0100, Lawrie wrote:
> [snip]>
> >For a datatype like a variable precision number this becomes a real pain.
> >Unless I am wrong, given a type like
> >
> >type NUMBER
> > INTEGER :: exp
> > INTEGER, POINTER :: sig(:)
> >ENDTYPE NUMBER
> >
> >there is no way of declaring something that would be equivalent to
> >
> >type(NUMBER),PARAMETER :: zero = 0
> >
> >no matter what circumlocutions one goes through.
> >
> 
> Can't you do
> 
> type (NUMBER), PARAMETER ::  zero = NUMBER(0,null())
This may be allowed but is only valid for the value zero and then only if a 
disassociated sig(:) is defined as a representation for zero.
For any other value the field to be pointer assigned by the intrinsic 
constructor to <number>%sig must have the TARGET attribute but it is 
explicitly forbidden for any declaration of an object that is both a target 
and a parameter.
type(NUMBER),PARAMETER :: one = NUMBER(0,(/1/))
fails because the array constructor does not have the TARGET attribute.
INTEGER,TARGET :: tone(0:0)=(/1/)
type(NUMBER),PARAMETER:: one=NUMBER(0,tone)
fails since tone is a variable and is not allowed in an initialisation 
expression.
> 
> I think I've tried that and it usually works (depends on the compiler).
> 
> If you want the type or constructor to be private then I think you'd
> have to define all of the popular parameters (0, 1, whatever) yourself in
> the module and make them public.
This is certainly true, but I contend I can not even do it for a few selected 
constants in the defining module.
> 
> I'm pretty sure that F2k will allow overloading of the type constructor,
> so a person could do something like
> type (NUMBER), parameter ::  zero = NUMBER('do whatever you need to make &
>    &                                        the value be a zero')
Allowing overload of the constructor was something I proposed first for F90 
and again for F95. It helps but not for PARAMETERs unless the restrictions on 
initialisation expressions are relaxed. It may be that we may need to 
introduce a CONSTANT object as distinct from a PARAMETER that can be defined 
by a relaxed specification expression rather than an initialisation one, but 
a CONSTANT once defined cannot be redefined.
> 
> and this is supposed to (in my opinion) work even though the type is
> private.  The module/type author merely needs to provide overloads for
> NUMBER that decode the arguments in The Right Way.
> 
> In thinking about it I bet there isn't a good way to do parameters.  The
> idea of a user defined function on the right hand side of a parameter
> definition will be hard to get right in the standard.  Since the
> likely case will be setting to zero maybe we could/should allow a
> type constructor with no arguments to supply the appropriate version
> of zero for everything.  Whatever is used as default for EOSHIFT and NULL()
> if the component is a parameter.
> 
> Dick Hendrickson
> 

--
Lawrie Schonfelder
Director, Computing Services Dept.
The University of Liverpool, UK, L69 7ZF
Phone: 44(151)794 3716, Fax: 44(151)794 3759




