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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.149.140 with SMTP id x134mr746481iod.65.1513631660542; Mon, 18 Dec 2017 13:14:20 -0800 (PST) X-Received: by 10.157.67.108 with SMTP id y41mr39627oti.5.1513631660394; Mon, 18 Dec 2017 13:14:20 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.kjsl.com!usenet.stanford.edu!g80no40872itg.0!news-out.google.com!b73ni220ita.0!nntp.google.com!g80no40870itg.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 18 Dec 2017 13:14:19 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:191:8303:2100:1cb4:b7ea:f38e:cb2d; posting-account=fdRd8woAAADTIlxCu9FgvDrUK4wPzvy3 NNTP-Posting-Host: 2601:191:8303:2100:1cb4:b7ea:f38e:cb2d References: <6bedbdee-ca7f-4d2a-83f9-6cc9c53d21cb@googlegroups.com> <3c367d8d-351e-4c72-b259-c04a5285d025@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: how to do things like procedure foo(A: string) is bar: string := A; begin; ...;end; From: Robert Eachus Injection-Date: Mon, 18 Dec 2017 21:14:20 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:49520 Date: 2017-12-18T13:14:19-08:00 List-Id: On Monday, December 18, 2017 at 10:34:50 AM UTC-5, Mehdi Saada wrote: =20 > Not sure about the constrained formal parameter part. What happens when y= ou call something like > function FOO(T: String range 5..9) return String; > with a parameter whose index subtype's bounds are say, 1..4 ? You say it = would raise Constraint_Error ? If so I can see the point. There's never too= much facultative checks. Yes, the bounds don't have to match, but the lengths do. (I hope the differ= ent lengths were not a typo.) However, there is another problem. Way, way= back subroutine parameters were changed to eliminate range constraints. Y= ou can say: subtype PS is String range(1..4); subtype TS is String range(5..9); procedure Foo(T: TS); ... Foo(PS); --raises Constraint_Error Foo('X' & PS); -- OK. But: procedure Foo(T: String range 5..9)... -- will fail at compile time. Why were formal parameters changed to eliminate (syntatic) constraints? Th= ey didn't accomplish much other than to confuse users. You can get the sam= e effect by using explicit subtype declarations--as above--if you want it. = Making things explicit helps both reader and programmer in those cases.