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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,61e9062c1f23b9d5 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!h2g2000hsg.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Reconsidering assignment Date: Thu, 07 Jun 2007 00:15:46 -0700 Organization: http://groups.google.com Message-ID: <1181200546.608422.95280@h2g2000hsg.googlegroups.com> References: <1181165630.012508.55290@i38g2000prf.googlegroups.com> NNTP-Posting-Host: 137.138.37.241 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1181200546 4771 127.0.0.1 (7 Jun 2007 07:15:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 7 Jun 2007 07:15:46 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070601 Red Hat/1.5.0.12-0.1.slc3 Firefox/1.5.0.12,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: h2g2000hsg.googlegroups.com; posting-host=137.138.37.241; posting-account=Ch8E9Q0AAAA7lJxCsphg7hBNIsMsP4AE Xref: g2news1.google.com comp.lang.ada:16086 Date: 2007-06-07T00:15:46-07:00 List-Id: On 7 Cze, 00:52, Ray Blaak wrote: > > procedure To_Upper(S : in out String); > > > Such a procedure is perfectly reasonable. > > What is not reasonable is this: > > > procedure Swap(X, Y : in out String); > > I don't see the difference. Consider: > > declare > s : String := "123"; > begin > To_Upper(s); > end; > > procedure To_Upper(S : in out String) > begin > s := "12345678"; > end; Good point, but the solution is simple: ban it. :-) You can ban it on the basis that the modifying operation (the s := "12345678") operates in (ie. potentially modifies) the constraint- space in the context where the constraint itself is statically unknown. This is OK: procedure To_Upper(S : in out String) is begin for I in S'First .. S'Last loop S(I) := ...; end loop; end; Above none of the modifying operation (well, there is only one) operates in the constraint-space of S. > > procedure Safe_Swap(X, Y : in out String) with X'Length = Y'Length; > > Ugh. This is tedious. Seems easier to me to just let the contraint error happen. The whole Ada is tedious. Let's move to Python, where even the chore of writing begin/end is eliminated. ;-) > If you really need this, also have a way to just say "with matching > constraints" directly, e.g. > > with X'Subtype = Y'Subtype > > That way one does not have to get all explicit for other types that have many > explicit constraints. Yes, that makes sense. -- Maciej Sobczak http://www.msobczak.com/