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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,81bb2ce65a3240c3 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.204.154.133 with SMTP id o5mr1260555bkw.0.1337315397240; Thu, 17 May 2012 21:29:57 -0700 (PDT) MIME-Version: 1.0 Path: e27ni7001bkw.0!nntp.google.com!news2.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!news.musoftware.de!wum.musoftware.de!news.albasani.net!nuzba.szn.dk!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: What would you like in Ada202X? Date: Thu, 17 May 2012 23:28:33 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <3637793.35.1335340026327.JavaMail.geo-discussion-forums@ynfi5> <172r5u18q2247.ze0a856uvhqt.dlg@40tude.net> <1nmd7pjdxlzs1.cwtljox0244r.dlg@40tude.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1337315319 30321 69.95.181.76 (18 May 2012 04:28:39 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 18 May 2012 04:28:39 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2012-05-17T23:28:33-05:00 List-Id: "Niklas Holsti" wrote in message news:a1l30fFuqaU1@mid.individual.net... > On 12-05-15 09:30 , Randy Brukardt wrote: ... >> (I don't think there are many routines >> that take "out" String parameters, because you can't change the size that >> way.) > > But in general, how would "out" parameters of type Root_String'Class (or > SomeType'Class) work? Of course the subprogram can call operations like > Set_Char on the parameter to alter its value, but what about a > whole-object assignment, Parameter := Value? I guess that must raise > Constraint_Error if the new Value does not match the actual Parameter in > type or discriminants. Right, but keep in mind that's how it works for composite types in Ada now. (The bounds and discriminants are passed in with the parameter, and usually you can't change them.) So we're not losing anything here, especially as the current types are arrays, for which you can never change the bounds. ... > Same sentiments here (I assume by "limited cases" you don't mean "limited > types" in the Ada sense). The main limitation, I think, is that the > derived type cannot be much more "meaningful" -- that is, carry more > information -- than the parent type; if it is, the conversion from parent > to derived would have to supply the additional information, from nothing. > >> (surely including your enumeration example). > > I don't think so, because the "deepened" enumeration type has more > information than the parent type. In the example I gave, the derived-type > literals Read and Write convert to the parent-type literal Request, but > the conversion back from Request to the derived type would have to choose > either Read or Write, and it has no information to guide that choice. Well, the technique still works, and about the same as your proposal: the reverse conversion just would raise an exception in the case where it cannot figure out what to do. That might be always in some situations, but it might also only have to do so in limited circumstances, so there would be more flexibility than your specific proposal would give. The only loss would be a compile-time vs. a run-time check. But that could be handled with a way to specify that there is no reverse conversion: with Parent_Conversion => My_Function, Reverse_Parent_Conversion => <>, ... in which case any uses of that conversion would have to be rejected at compile-time. (There might be a generic contract problem with this particular idea, though.) Randy.