Version 1.1 of acs/ac-00052.txt

Unformatted version of acs/ac-00052.txt version 1.1
Other versions for file acs/ac-00052.txt

!standard 7.3(00)          03-01-23 AC95-00052/01
!class amendment 03-01-23
!status received no action 02-10-11
!subject Private discrete types
!summary
!appendix

!topic Private discrete types?
!reference AI95-00037, RM95 B.3, 7.3
!from Adam Beneschan 02-10-11
!discussion

I ran across this old comment from Keith Thompson regarding
Interfaces.C, in AI95-00037:

>> May the type Interfaces.C.Char be declared as
>>     type char is new Character;
>> ?
>>
>> May Interfaces.C.wchar_t be declared as
>>     type wchar_t is new Wide_Character;
>> ?
>>
>> If so, type conversions between Character and char, and between
>> Wide_Character and wchar_t, are legal under some implementations and
>> not under others.

Also, using character literals for the wchar_t type would be legal
under some implementations and not others.

>> Given the wording in the RM, I believe the answer is yes in both cases.
>> This is an interesting source of quietly non-portable programs.

This could be solved by making the type wchar_t private, but that make
many operations illegal that are currently legal (such as
wchar_t'first, 'succ, etc.)

What I'm wondering is: Has the notion of a "discrete private" type
been discussed before?  If so, did it seem potentially useful, too
esoteric, too difficult to implement, or what?  I don't see any AI
that deals with this.

The idea is that you could define something like

    type T is private (<>);

(or, to be really consistent with generics:)

    type T is (<>);

where the full view of T would have to be a discrete type.  The
partial view of T would then have all the predefined attributes
available to discrete types (3.5(10-55), 3.5.5), and could be used
anywhere the language requires a discrete or scalar type (e.g. in a
FOR loop, in the index part of an array definition, as an actual
for a generic formal discrete type, etc.).

My first guess is that implementing this new feature wouldn't be
terribly difficult, since the compiler would do a lot of the same
things it already has to do for generic formal discrete types.

If this declaration were available and were used in Interfaces.C, this
would address Keith's objection and prevent certain nonportable
operations from being used on wchar_t, while still allowing all the
operations normally available for discrete types.  I imagine it might
be useful in other situations too, but I don't know for sure.

****************************************************************

Questions? Ask the ACAA Technical Agent