comp.lang.ada
 help / color / mirror / Atom feed
From: eachus@mitre-bedford.arpa  (Robert I. Eachus)
Subject: Re: putting default value on a subtype of an undefaulted type.
Date: 26 May 93 19:29:07 GMT	[thread overview]
Message-ID: <EACHUS.93May26142907@spectre.mitre.org> (raw)

In article <C7n3wB.BGJ@crdnns.crd.ge.com> groleau@e7sa.crd.ge.com (Wes Groleau 
X7574) asks:

 >  Situation:
 >	 type NO_DEFAULT ( Discrim : NATURAL ) is
 >	    record
 >	       A : SOME_TYPE;
 >	       B : STRING ( 1 .. Discrim );
 >    end record;

 >  Problem:
 >	 1. The type declaration is not mine but I'm forced to use it.
 >	 2. Can't declare objects of that type without constraining them
 >	    to a fixed value of Discrim.

 >   Question:
 >	 What is the syntax for creating a subtype with the same set of values
 >	 as the original type but which has a default discriminant?  

     You can't.  Records such as this (but with defaults) are a very
magic animal in Ada, and will almost certainly be represented in a
very different way.  Alternatives are:

     1) Create your own varying type, and call explict conversion
functions where necessary.

     2) Use declare blocks where you need to create objects.  (The
size of objects need not be static, just set when the object is
created.)

     3) Go beat on the supplier of the type to provide a type with a
default.


 >  Curiosity:
 >	 What is the syntax for giving A a default value in a subtype? 

    Again, not a supported feature.

--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...

             reply	other threads:[~1993-05-26 19:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-05-26 19:29 Robert I. Eachus [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-05-26 18:04 putting default value on a subtype of an undefaulted type dog.ee.lbl.gov!overload.lbl.gov!agate!howland.reston.ans.net!noc.near.net
1993-05-26 15:57 Michael Feldman
1993-05-26 15:19 Wes Groleau X7574
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox