comp.lang.ada
 help / color / mirror / Atom feed
From: Jacob Sparre Andersen <sparre@nbi.dk>
Subject: Re: Range types
Date: Mon, 22 Oct 2007 09:23:01 +0200
Date: 2007-10-22T09:23:01+02:00	[thread overview]
Message-ID: <ygefy034nqi.fsf@hugsarin.dmusyd.edu> (raw)
In-Reply-To: 471BC497.5060601@gmail.com

Christos Chryssochoidis wrote:

> I would like to define a subtype of Wide_Character for a program
> that processes (unicode) text. This type would represent the Greek
> letters.

This sounds like what enumerated types are for.  You could do it like
this:

   type Faroese_Letter is ('a', 'A', 'b', 'B', 'd', 'D', '�', '�',
                           'e', 'E', [...],
                           'y', 'Y', '�', '�', '�', '�', '�', '�');
   -- optional representation clause

   function To_Wide_Wide_Character (Item : in Faroese_Letter)
     return Wide_Wide_Character;

   function To_Faroese_Letter (Item : in Wide_Wide_Character)
     return Faroese_Letter;

The conversion functions could make use of representation clauses,
"Image" and "Value" functions, or tables.

> 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.

This could be done very simply using Ada.Strings.Maps.

How you should do it depends strongly on what you actually need your
Greek_Letter type for.

Greetings,

Jacob
-- 
"Only Hogwarts students really need spellcheckers"
                                -- An anonymous RISKS reader



  parent reply	other threads:[~2007-10-22  7:23 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
2007-10-22  0:06     ` Robert A Duff
2007-10-22  7:23     ` Jacob Sparre Andersen [this message]
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