comp.lang.ada
 help / color / mirror / Atom feed
* Newbie question about  Character range 'A' .. 'Z'
@ 2000-05-16  0:00 gressett
  2000-05-17  0:00 ` Florian Weimer
  0 siblings, 1 reply; 2+ messages in thread
From: gressett @ 2000-05-16  0:00 UTC (permalink / raw)


I am learning Ada from the book Ada as a Second Language, by Norman
H. Cohen. (3rd printing)

In chapter 3, starting at the end of page 131 is a sample procedure,
Count_Letters, which contains errors which are corrected  in the
errata page at the web site for the book. The problem it that

'A' .. 'Z'

is intended to be a Character range, but is ambiguous because it
cannot be distinguished from a Wide_Character range.

The errata page states that all occurrences of 'A' .. 'Z' should be
replaced with Character range 'A' .. 'Z', even in the line

if Next_Char in 'A' .. 'Z' then

where the declaration of Next_Char as a Character removes the
ambiguity. The errata page suggests that this is for consistency, as
the rules of the language do not require an explicit Character range
here.

The Gnat 3.12p compiler, however, prohibits the Character range,
producing the error message "range constraint not allowed in
membership test"

Is Gnat 3.12p being overly restrictive, or is the erratum wrong?




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Newbie question about  Character range 'A' .. 'Z'
  2000-05-16  0:00 Newbie question about Character range 'A' .. 'Z' gressett
@ 2000-05-17  0:00 ` Florian Weimer
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Weimer @ 2000-05-17  0:00 UTC (permalink / raw)


gressett@iglobal.net writes:

> Is Gnat 3.12p being overly restrictive, or is the erratum wrong?

The ARM says (3.5 and 4.4):

|  2.      range_constraint ::= <range> range
|
|  3.      range ::=
|               range_attribute_reference
|             | simple_expression .. simple_expression

|  3.      relation ::=
|               simple_expression [relational_operator simple_expression]
|             | simple_expression [<not>] <in> range
|             | simple_expression [<not>] <in> subtype_mark

GNAT seems to be right.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-05-17  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-16  0:00 Newbie question about Character range 'A' .. 'Z' gressett
2000-05-17  0:00 ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox