From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,51ab506286e54a43 X-Google-Attributes: gid103376,public From: "Robert I. Eachus" Subject: Re: Subtypes do not Statically Match Date: 1999/07/02 Message-ID: <377D152C.663E5A1C@mitre.org>#1/1 X-Deja-AN: 496534191 Content-Transfer-Encoding: 7bit References: <377A8C1A.6EFE0FF7@boeing.com> <7lec49$sgn$1@bgtnsc03.worldnet.att.net> <377B9FF6.7829A681@boeing.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: The MITRE Corporation Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-07-02T00:00:00+00:00 List-Id: John Harbaugh wrote: > Thanks for the example solution. Yes, it does work. Interestingly, > using a constrained subtype of String cures the subtype mismatch in the > original post, but the problem then mutates into accessibility > violations. I just wanted to know if there is a way to convert or > qualify the subtype so as to achieve a match. From what I've read so > far, the answer is no. Correct, but so far no one has told you why it is no. Normally in Ada a string (for now assume a parameter S: String) is an object with both bounds and a matching array of characters. But you can have a subtype Four_String is Sring(1..4); In this case objects of the subtype don't need to be stored with bounds, but if they are passed to a procedure with a parameter of type String, the compiler must create an object with included bounds to pass. Now for the compilication in your case. The record component has a subtype that depends on a discriminant. The compiler has to compute bounds for the component from the discriminant, therefore the string subcomponent may not be stored with bounds included, so there is no object to point to that looks like a normal string. The best fix is to use unbounded strings from Annex A. These will meet your requirements and do what you want. You can also write a package like this, or like bounded_strings yourself, but why duplicate effort? -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...