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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!news-in-01.newsfeed.easynews.com!easynews!core-easynews-01!easynews.com!en-nntp-13.dc1.easynews.com.POSTED!not-for-mail From: agent@drrob1.com Newsgroups: comp.lang.ada Subject: Re: character literals Message-ID: References: <9d08b5d0-012c-4b94-b8b9-ea6e83f2df4f@googlegroups.com> User-Agent: ForteAgent/7.20.32.1218 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@easynews.com Organization: Forte Inc. http://www.forteinc.com/apn/ X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly. Date: Tue, 11 Feb 2014 20:34:20 -0500 X-Received-Bytes: 2382 Xref: news.eternal-september.org comp.lang.ada:18495 Date: 2014-02-11T20:34:20-05:00 List-Id: On Tue, 11 Feb 2014 16:18:36 -0800 (PST), adambeneschan@gmail.com wrote: >On Tuesday, February 11, 2014 3:56:52 PM UTC-8, I wrote: > >>>> IF ch in '0' .. '9' THEN > >> I don't think your compiler should not be giving an "ambiguous" error on the above IF statement. The literals '0' and '9' are indeed ambiguous, because they are actually overloaded functions that could return Character, Wide_Character, or Wide_Wide_Character, or possibly one or more user-defined enumeration types; however, assuming "ch" is a variable, it will have a known type, and I think that type can be used to resolve the types of the overloaded range. However, on checking the language rules, it's not 100% clear to me that that's the case. Neither compiler I tried this on reports an error, though. > >After taking another look at the rules, I'm convinced that this IF statement is indeed legal. > > -- Adam It is a For statement that caused the compiler to complain. I fixed this by declaring chardgt0 : constant Character := '0'; chardgt9 : constant character := '9'; But now I don't know why this function is failing. I want to convert a character value to its integer value. Modula-2 used the built-in function ORD for this purpose. This fails type checking I := Natural'Value(CH); -- assume I is natural and ch is character So I tried this s: string(1..1); s(1) := ch; I := Natural'Value(s); This fails saying Constraint_Error explicit raise I don't get it