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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Nasser M. Abbasi" Newsgroups: comp.lang.ada Subject: Re: Haskell, anyone? Date: Sun, 15 Nov 2015 23:17:06 -0600 Organization: Aioe.org NNTP Server Message-ID: References: <87mvue50ey.fsf@ixod.org> <87d1vaoa6y.fsf@nightsong.com> Reply-To: nma@12000.org NNTP-Posting-Host: xsLQkk658PrKN3IVMCswbw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:28388 Date: 2015-11-15T23:17:06-06:00 List-Id: On 11/15/2015 10:11 PM, Paul Rubin wrote: > range, or throws an error otherwise. This is called a "smart > constructor" in Haskell. I think Ada's range types are similar: if X, > Y, and Z are in that 1..20 range type and X=15 and Y=15, then Z:=X+Y is > a legal Ada statement that doesn't raise any error until runtime. It is detected at compile time. It gives warning. So compiler can see at compile time the problem. >cat foo.adb with ada.text_io; use ada.text_io; procedure foo is type I is range 0 .. 20; x,y : I :=15; z : I :=0; begin z:= x + y ; end foo; >gnatmake foo.adb gcc-4.8 -c foo.adb foo.adb:8:12: warning: value not in range of type "I" defined at line 4 foo.adb:8:12: warning: "Constraint_Error" will be raised at run time --Nasser