comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: IBM 437 encoded String to UTF-16 Wide_String
Date: Wed, 28 Nov 2012 14:36:02 +0100
Date: 2012-11-28T14:36:02+01:00	[thread overview]
Message-ID: <347rnekt4in1.12pbyz0phdelf$.dlg@40tude.net> (raw)
In-Reply-To: 50b5f60e$0$9524$9b4e6d93@newsspool1.arcor-online.net

On Wed, 28 Nov 2012 12:31:35 +0100, Georg Bauhaus wrote:

> On 28.11.12 10:58, Dmitry A. Kazakov wrote:
>>  When I mentioned Wide_Wide_String I meant an array of code points. The
>> logical view of *any* string type is array of code points. The only
>> difference between different string types is in the constraints put on the
>> code points. E.g. String has code points 0 to 255. IBM_437_String would
>> have a non-contiguous set of code points etc.
> 
> What is a non-contiguous set?

A convex set in this case, i.e.:

for code points x,y,z, such that x<y<z if x,z in S then y in S

> In case of differentiation by sets of code points, I'd rather
> have an honest type Unicode_String and---if we are already
> fixing the language---put everything that has {Wide_}String
> in its name in Annex J.
> 
> But then, consider
> 
>     type Index is range 1 .. 12;
> 
>     type R is ('I', 'V', 'X', 'L', 'C', 'D', 'M');
> 
>     type N is array (Index range <>) of R;
> 
> A string of R, named N here, is just fine. In fact,
> 
>     Year : constant N := "MCMLXXXIII";
> 
> has a valid literal, and the year so written is not of any of
> the standard string types. The definition of type R actually
> implies a codespace, and, for example, Character'('V') or
> Wide_Character'('V') have no role in it, irrespective of
> any accidental overlap in encoding or representation or
> position.
> 
> So, which by force should type N be in Whatever_String'Class?

Per inheritance:

   type N is
      new Wide_Wide_String
      and array (...) of R;

>>> As a practical alternative, why not add a generalized
>>> std::valarray<type T = (<>)> to the language instead
>>> of fixing it?
>>
>> No idea what this is supposed to mean.
> 
> Call it
> 
> generic
>     type Element_Type is ...
>     type Index_Type is ...
> package Ada.Containers.Tuples is
>     ...
> 
> and make it have standard container operations, extended as needed.

It does not solve anything. The problem is not construction of a container
type. It is the relation of the obtained type to the string interface. The
string interface is an array of code points. The container must implement
this interface in order to be a string. All strings must implement this
interface, this is why they are called "strings."

> The idea is that if Element_Type is ordered scalars, and if container
> operations provide for writing algorithms efficiently, then
> that's a more practical way of having strings of anything
> than, say, finally removing "tagged" from the language and make
> every type be in some 'Class.

Every type is in more than just one class, trivially.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2012-11-28 13:36 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-27 21:02 IBM 437 encoded String to UTF-16 Wide_String gautier_niouzes
2012-11-27 21:38 ` J-P. Rosen
2012-11-27 22:12 ` gautier_niouzes
2012-11-27 22:14 ` Dmitry A. Kazakov
2012-11-27 23:13   ` gautier_niouzes
2012-11-27 23:41 ` Vadim Godunko
2012-11-28  8:34   ` briot.emmanuel
2012-11-28  8:52     ` Dmitry A. Kazakov
2012-11-28  9:43       ` Georg Bauhaus
2012-11-28  9:58         ` Dmitry A. Kazakov
2012-11-28 11:31           ` Georg Bauhaus
2012-11-28 13:36             ` Dmitry A. Kazakov [this message]
2012-11-28 13:47               ` Georg Bauhaus
2012-11-28 14:23                 ` Dmitry A. Kazakov
2012-11-28 17:35                   ` Georg Bauhaus
2012-11-28 18:00                     ` Dmitry A. Kazakov
2012-11-29  9:51                       ` Georg Bauhaus
2012-11-29 10:52                         ` Dmitry A. Kazakov
2012-11-29 14:05                           ` Georg Bauhaus
2012-11-29 21:03                             ` Dmitry A. Kazakov
2012-11-29  3:18             ` Randy Brukardt
2012-11-28 13:51     ` gautier_niouzes
replies disabled

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