comp.lang.ada
 help / color / mirror / Atom feed
From: Christos Chryssochoidis <C.Chryssochoidis@gmail.com>
To: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Range types
Date: Mon, 22 Oct 2007 00:28:55 +0300
Date: 2007-10-22T00:28:55+03:00	[thread overview]
Message-ID: <471BC497.5060601@gmail.com> (raw)
In-Reply-To: <471bb318$0$27835$39db0f71@news.song.fi>

Niklas Holsti wrote:
> 
> Christos Chryssochoidis wrote:
>> Hi,
>>
>> I have a question regarding the range types in Ada. Is there any way 
>> to specify that a type is, say, the values 1..100 and additionally the 
>> values 150..200?
> 
> Brief answer: sorry, no. You cannot leave gaps in the range of numeric 
> types.
> 
> You could define an enumeration type with 151 literals and write a 
> "representation clause" for this type that would force the compiler to 
> use the values 1 .. 100 as the internal representation of the first 100 
> literals and the values 150 .. 200 as the internal representation of the 
> last 51 literals. This would override the the default internal 
> representation that uses the values 0 .. 150 in order. But you could not 
> do direct arithmetic (plus, minus, ...) on such a type because those 
> operations are not predefined for enumeration types.
> 
> Perhaps you could explain why you need a type with a gap?
> 

I would like to define a subtype of Wide_Character for a program that 
processes (unicode) text. This type would represent the Greek letters. 
Greek letters in Unicode, with all their diacritics, are located in two 
separate ranges: 0370 - 03D7 and 1F00 - 1FFF. That's 360 characters to 
write in an enumeration... Since gaps are not allowed in ranges, I 'm 
thinking instead of defining such a type, to define a function that 
would accept a Wide_Character as argument and return a boolean value 
indicating whether the given Wide_Character falls in the ranges of the 
Greek characters.

Thanks very much,

C.C.



  reply	other threads:[~2007-10-21 21:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-21 19:15 Range types Christos Chryssochoidis
2007-10-21 20:23 ` Niklas Holsti
2007-10-21 21:28   ` Christos Chryssochoidis [this message]
2007-10-22  0:06     ` Robert A Duff
2007-10-22  7:23     ` Jacob Sparre Andersen
2007-10-22 11:14       ` Christos Chryssochoidis
2007-10-22 12:33         ` Georg Bauhaus
2007-10-22 19:08           ` Christos Chryssochoidis
2007-10-23 23:52         ` anon
2007-10-24 12:57           ` Christos Chryssochoidis
2007-10-21 21:53 ` anon
2007-10-21 22:38   ` Christos Chryssochoidis
replies disabled

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