comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: IBM 437 encoded String to UTF-16 Wide_String
Date: Wed, 28 Nov 2012 18:35:06 +0100
Date: 2012-11-28T18:35:03+01:00	[thread overview]
Message-ID: <50b64b47$0$6571$9b4e6d93@newsspool3.arcor-online.net> (raw)
In-Reply-To: <11j81z9v2gr02$.kxnnq6lqzoz$.dlg@40tude.net>

On 28.11.12 15:23, Dmitry A. Kazakov wrote:
> On Wed, 28 Nov 2012 14:47:10 +0100, Georg Bauhaus wrote:
> 
>> On 28.11.12 14:36, Dmitry A. Kazakov wrote:
>>> 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."
>>
>> This says that a string interface consists of operations
>> that allow us to use string objects like one uses arrays.
> 
> It say that instance implementing the interface are substitutable where a
> string is expected. You should be able to pass IBM_437_String to Put_Line,
> Trim, To_Lower etc.
> 
>> Is this set of array ops not included in a Vector's interface,
> 
> By which means the language or the reader knows if it is?

This is why I mentioned generics. It is not nice, but lets the
reader see the expected interface:

   generic
      type Apple is (<>);

      with package V is
        new Ada.Containers.Vectors (Element_Type => Apple,
                                    others => <>);
   package String_Ops is

      type String is new V.Vector with null record;

      Pattern_Error : exception;

      procedure Put_Line (Source : String);  -- not normally here

      function Slice (Source : String;
                      Low    : V.Index_Type;
                      High   : V.Extended_Index) return String;

      function Index (Source, Pattern : String) return V.Extended_Index;

   end String_Ops;

Or even

   generic
      type Element_Type is ...
   package Ada.Containers.Strings is ...

I don't prefer these types of generics to an improved type system,
one that is less complex and less full of historical reasons.
But since Ada is not going to get this sort of type system...

> Ada had manifesting type system, so far...
> 
>> Which algorithms require a String_Interface that excludes
>> other array/vector operations?
> 
> ?

That is, is there a set difference between string operations
and "vector" operations such that, from a user's perspective,
nothing could turn vectors into objects of type String, or
Wide_String, or Wide_Wide_String?




  reply	other threads:[~2012-11-28 17:35 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
2012-11-28 13:47               ` Georg Bauhaus
2012-11-28 14:23                 ` Dmitry A. Kazakov
2012-11-28 17:35                   ` Georg Bauhaus [this message]
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