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: 103376,640b65cbfbab7216 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news1.google.com!news.glorb.com!newscon02.news.prodigy.net!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Ada.Bounded_Strings Date: Fri, 04 Apr 2008 19:35:37 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <47F26C46.3010607@obry.net> <44d88b93-6a90-4c18-8785-2164934ba700@a9g2000prl.googlegroups.com> <47F652F7.9050502@obry.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1207352138 6283 192.74.137.71 (4 Apr 2008 23:35:38 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 4 Apr 2008 23:35:38 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:iUovDTWDAPVfDGivRMtJ3e4CJlc= Xref: g2news1.google.com comp.lang.ada:20826 Date: 2008-04-04T19:35:37-04:00 List-Id: Adam Beneschan writes: > The disadvantage of this approach was given as this: "[P]redefined > assignment and equality for discriminated Bounded_String do not have > the desired behavior. Assignment makes sense when the maximum lengths > of source and target are different, as long as the source's current > length is no greater than the target's maximum length, yet predefined > ":=" would raise Constraint_Error on the discriminant mismatch". > > The reason this doesn't make sense to me is, how does the generic > definition solve the problem? It doesn't, but it does cause the problem to be prevented statically, rather than via an exception at run time. As far as I know, there is no way to actually solve the problem in Ada -- that is, allow all the assignments that make sense, and no others. I must admit, that generic seems awfully heavy. Part of the rationale (rationalization?) was that you can just pick some reasonable max length, and instantiate the thing once, and use it all over your program. - Bob