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,61e9062c1f23b9d5 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!inka.de!rz.uni-karlsruhe.de!news.belwue.de!th!lucks From: Stefan Lucks Newsgroups: comp.lang.ada Subject: Re: Reconsidering assignment Date: Thu, 7 Jun 2007 13:11:10 +0200 Organization: InterNetNews at News.BelWue.DE (Stuttgart, Germany) Message-ID: References: <1181165630.012508.55290@i38g2000prf.googlegroups.com> <1181201522.974849.163960@o5g2000hsb.googlegroups.com> NNTP-Posting-Host: th.informatik.uni-mannheim.de Mime-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-1685695141-1539505011-1181214670=:12475" X-Trace: news.BelWue.DE 1181214672 28990 134.155.91.85 (7 Jun 2007 11:11:12 GMT) X-Complaints-To: news@news.belwue.de NNTP-Posting-Date: Thu, 7 Jun 2007 11:11:12 +0000 (UTC) In-Reply-To: <1181201522.974849.163960@o5g2000hsb.googlegroups.com> Xref: g2news1.google.com comp.lang.ada:16089 Date: 2007-06-07T13:11:10+02:00 List-Id: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---1685695141-1539505011-1181214670=:12475 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8BIT On Thu, 7 Jun 2007, Maciej Sobczak wrote: > declare > I : Integer; > P : Positive; > begin > I := Make_Positive; -- OK, looks "innocent", cannot raise > P := Make_Integer; -- should be error ("innocent" lies) > P := (Positive)Make_Integer; -- OK, beware potential errors > end; If I wanted to ensure P := Make_Integer is a compile-time error, I would define Positive as a type, instead of a subtype. OK, then I would have to write I := Integer(Make_Positive), but � would not regard this as too much of a problem. Either I want the ease of mixing my types, see (2) below, in which case I use the "subtype" Ada syntax, or I want the firewall between types, where I use "type", see (1). type Pos_T is new Integer range 1 .. Integer'Last; -- (1) subtype P_Sub is Integer range 1 .. Integer'Last; -- (2) The distinction between "subtype" and "type" helps to write correct and easy-to-read programs. I don't think however, that making subtypes more type-like ("type" in the sense of the Ada syntax) would help at all. BTW, you would not get rid of innocent lies, anyway. See th following exampes: Odd_Number := Make_Positive; Prime := Make_Positive; These are innocent-looking but semantically wrong (assuming the constraints suggested by the choice of the identifiers). Now, please define an advanced type system to statically enforce such constraints! (You could perhaps statically enforce them by the aid of static analysis tools, such as the SPARK toolset.) -- Stefan Lucks (moved to Bauhaus-University Weimar, Germany) ------ I love the taste of Cryptanalysis in the morning! ------ ---1685695141-1539505011-1181214670=:12475--