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=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,c02604a46964120 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news3.google.com!feeder1.cambriumusenet.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!193.201.147.68.MISMATCH!feeder.news-service.com!news.k-dsl.de!aioe.org!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Noob question: universal_integer type Date: Sat, 22 May 2010 01:33:02 +0200 Organization: Ada At Home Message-ID: References: NNTP-Posting-Host: yVqnXu8PM2YoL9CUr8z5jg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: Opera Mail/10.53 (Win32) Xref: g2news2.google.com comp.lang.ada:11862 Date: 2010-05-22T01:33:02+02:00 List-Id: Le Sat, 22 May 2010 01:15:19 +0200, Duke Normandin = a = =C3=A9crit: > Coronado's Ada tutorial - Chapt3 > > [quote] > The constant 17 is of a very special type defined by Ada as type > "universal_integer" which can be combined with any of the integer type= s > without specific conversion. > [/quote] > > Let me get this right... if I use an undeclared integer in an expressi= on, > Ada will "deem it" to be a "universal_integer" and not choke at > compile-time? On this subject, you may like to read a previous thread named =E2=80=9CI= nteger = questia=E2=80=9D. Here is a Google Group link for conveniance: http://groups.google.com/group/comp.lang.ada/browse_thread/thread/d9d2bc= cce5d4fc93# The key, is that universal integer, is a type like other types you may = defined. Every type integer-like type can be converted to and from = universal integer. So, yes, the compiler will not complain, because if you have My_Constant : constant :=3D 1; -- Named number, that is here, univer= sal = integer. type My_Integer_Type is range 1 .. 9; My_Entity : My_Integer_Type :=3D My_Constant; the compiler will not see a contradiction, it will not see the declarati= on = of a given type which is initialized with a value of a different type, i= t = will see a literal, which it will automatically convert to the target ty= pe. -- = There is even better than a pragma Assert: a SPARK --# check.