From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 26 May 93 19:29:07 GMT From: eachus@mitre-bedford.arpa (Robert I. Eachus) Subject: Re: putting default value on a subtype of an undefaulted type. Message-ID: List-Id: In article 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...