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!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: character literals Date: Wed, 12 Feb 2014 10:53:24 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <9d08b5d0-012c-4b94-b8b9-ea6e83f2df4f@googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls7.std.com 1392220406 30508 192.74.137.71 (12 Feb 2014 15:53:26 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 12 Feb 2014 15:53:26 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:O9BI8Fm5pyrlMQz7zkTjILvCBWs= X-Received-Bytes: 2537 X-Received-Body-CRC: 3136862216 Xref: news.eternal-september.org comp.lang.ada:18504 Date: 2014-02-12T10:53:24-05:00 List-Id: adambeneschan@gmail.com writes: > On Tuesday, February 11, 2014 2:27:57 PM UTC-8, ag...@drrob1.com wrote: >> I have been having a difficulty in my code with character literals. >> >> For example >> >> IF ch in '0' .. '9' THEN Note to OP: If you have questions about an error message, it's best to cut&paste the exact complete compilable code that caused the error, along with the exact text of the error message. The above is legal given the right declaration of ch, but you didn't show that; there are all sorts of reasons the above could be illegal. Also look at Ada.Characters.Handling. You can call the Is_Digit function. > Finally, the language does have one special rule: > > for I in 0 .. 9 loop > > The literals 0 and 9 could be resolved to any integer type, which > would make this ambiguous since there are normally multiple integer > types visible in the program (Integer, Long_Integer, Short_Integer, > maybe types in Interfaces if you "use" that packaged). But the > language rules decree that the type will be Integer in that case. > This is a situation where some programmers might recommend making the > type Integer explicit. Like me. I think the special-case for Integer is a kludge, so I would write: for I in Some_Type range 0 .. 9 loop One exception: If I want to say "do this 5 times", I might write: for I in 1 .. 5 loop and there are no references to I in the loop, so its type is irrelevant. On the other hand, if the type is clear from the bounds, as in for I in 1 .. Some_Array'Last - 1 loop I wouldn't put the type in. - Bob