comp.lang.ada
 help / color / mirror / Atom feed
From: Stefan.Lucks@uni-weimar.de
Subject: Re: Is this expected behavior or not
Date: Fri, 5 Apr 2013 21:55:27 +0200
Date: 2013-04-05T21:55:27+02:00	[thread overview]
Message-ID: <alpine.DEB.2.02.1304052103590.31746@debian> (raw)
In-Reply-To: <pgrgoxdhtshv$.z253qtbqarkc.dlg@40tude.net>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 4534 bytes --]

On Fri, 5 Apr 2013, Dmitry A. Kazakov wrote:

> On Fri, 5 Apr 2013 17:16:59 +0200, Stefan.Lucks@uni-weimar.de wrote:

>> I agree with you that there is no reason to distinguish between them. The
>> entire distinction narrow, Wide_ and Wide_Wide_ Strings (and Characters)
>> is a historical artifact, no more, no less.
>>
>> But if there is no reason to disting between them -- there is no reason to
>> mix them either!
>
> Sorry, but it cannot be both.

No, if you mix them, you must distinguish them. At least, when 
implementing your own multi-method, such as

   function Longest_Common_Substring(S1, S2: Universal_String)
                                    return Universal_String;
                                              -- maybe "is abstract";

Either Universal_String is abstract, then so would be this multi-method, 
and you would to override it n^3 times, when supporting n different string 
types. Or you can actually have objects of type Universal_String, but then 
using this method without making explicit conversions means a whole new 
bunch of implicit conversions.

One problem with implicit conversions is that Strings don't "know" their 
encoding (Is it UTF-8? Or ISO-Latin-1? Or ...?), so you don't even have 
the information you need to perform the conversion. Which is why you need 
to make explicit conversions.

And then it is not a big leap to say "convert everything into my favourite 
kind of string, then call my method, and then convert the result back".

> Consider Ada.Text_IO.Create. It has name a string and content. You tell 
> us that it is not necessary to be able to open an UTF-8 file which name 
> is UTF-16? Blame Microsoft.

I know a lot of things to blame Microsoft for, but in the Unix world, all 
files are essentially sequences of bytes that you read or write, and it is 
your problem to know the semantic of these sequences. So this is not much 
better than in the Microsoft world.

In any case, Ada.Text_IO.Create is a good example.

As much as I understand you, if Name is of type Universal_String'Class and 
you call Ada.Text_IO.Create(File, Name) you expect the proper thing to 
happen, right?

I agree that this would be cool. But it just cannot work!

Right now, if the encoding of Name is, say, ISO-Latin-1 and the encoding 
the underlying filesystem expects is UTF-8, you can have really surprising 
results when calling Ada.Text_IO.Create(File, Name). It would be cool to 
solve this issue with some Universal_String type.

But firstly, the strings we have don't know their encoding. The 
application programmer knows (hopefully), but it is not part of String.

Secondly, even if we had some kind of enhanced string type with object 
Name storing its own encoding, in addition to the string itself, the 
library wouldn't know which encoding it to convert Name into, or if 
any conversion is needed at all!

The point is, you can mount different filesystems with different naming 
and encoding conventions, even on the same machine. (With Linux for 
sure, I guess that also works in the Microsoft world.)

No Universal_ type will solve this issue -- you just cannot get rid of 
explicit conversions. At the end of the day, something such as opening or 
creating a file is some kind of a low-level operation, alas.

>> I think, I agree with Randy here. The old bunch of strings are a mess,
>
> There is nothing wrong with them except for being not in the same class.
> [Literals could be done better]

> Furthermore what Randy proposes will actually be worse than pitiful
> Unbounded_String. For them you could at least do this:
>
>   type Relative_File_Path is new Unbounded_String;
>   type Absolute_File_Path is new Unbounded_String;
>
> You could not do that for tagged strings.

OK, here we agree. Whatever the "new" strings are, the ability to define 
incompatible types with the same representation, that you cannot mix 
(without explicit conversion) is important for a language supporting 
safety-critical stuff! I sometimes have types Tainted_String and 
Save_String, being both derived from [Wide_[Wide_]]String, and I am happy 
when the compiler stops me from messing up between variables of this type. 
Does Randy's proposal really not allow that?


------  I  love  the  taste  of  Cryptanalysis  in  the morning!  ------
     <http://www.uni-weimar.de/cms/medien/mediensicherheit/home.html>
--Stefan.Lucks (at) uni-weimar.de, Bauhaus-Universität Weimar, Germany--

  reply	other threads:[~2013-04-05 19:55 UTC|newest]

Thread overview: 242+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-11 19:42 Is this expected behavior or not Anh Vo
2013-03-11 20:01 ` Robert A Duff
2013-03-11 20:41   ` Shark8
2013-03-12  9:27     ` Dmitry A. Kazakov
2013-03-12 17:19       ` Robert A Duff
2013-03-12 17:42         ` Dmitry A. Kazakov
2013-03-12 18:04           ` Georg Bauhaus
2013-03-12 18:21             ` Dmitry A. Kazakov
2013-03-12 22:23               ` Georg Bauhaus
2013-03-13  8:49                 ` Dmitry A. Kazakov
2013-03-13  9:45                   ` J-P. Rosen
2013-03-13 13:31                     ` Dmitry A. Kazakov
2013-03-13 14:34                       ` Georg Bauhaus
2013-03-13 15:51                         ` Dmitry A. Kazakov
2013-03-13 16:56                           ` Jeffrey Carter
2013-03-13 17:09                             ` Shark8
2013-03-13 17:32                           ` Georg Bauhaus
2013-03-13 19:28                             ` Dmitry A. Kazakov
2013-03-13 21:01                               ` Randy Brukardt
2013-03-13 21:18                                 ` Dmitry A. Kazakov
2013-03-14 21:51                                   ` Randy Brukardt
2013-03-15  1:10                                     ` Adam Beneschan
2013-03-15 21:22                                       ` Randy Brukardt
2013-03-15  9:20                                     ` Dmitry A. Kazakov
2013-03-15 21:43                                       ` Randy Brukardt
2013-03-16  7:56                                         ` Dmitry A. Kazakov
2013-03-18 22:52                                           ` Randy Brukardt
2013-03-19 10:32                                             ` Dmitry A. Kazakov
2013-03-13 21:37                               ` Georg Bauhaus
2013-03-14 11:18                                 ` Dmitry A. Kazakov
2013-03-14 12:37                                   ` Georg Bauhaus
2013-03-14 14:26                                     ` Dmitry A. Kazakov
2013-03-14 14:57                                       ` Georg Bauhaus
2013-03-14 15:51                                         ` Anh Vo
2013-03-14 16:21                                       ` J-P. Rosen
2013-03-14 17:29                                         ` Dmitry A. Kazakov
2013-03-14 18:16                                           ` Georg Bauhaus
2013-03-15  9:33                                             ` Dmitry A. Kazakov
2013-03-15 10:05                                               ` Georg Bauhaus
2013-03-15 11:15                                                 ` Dmitry A. Kazakov
2013-03-14 22:12                                           ` Randy Brukardt
2013-03-15  9:46                                             ` Dmitry A. Kazakov
     [not found]                                             ` <ewe0v3ck1xdo$.e8rtuof27ke6$.dlg@40tude.net >
2013-03-15 21:17                                               ` Randy Brukardt
2013-03-16  7:51                                                 ` Dmitry A. Kazakov
2013-03-16  9:30                                                   ` Georg Bauhaus
2013-03-16 10:27                                                     ` Dmitry A. Kazakov
2013-03-16 11:37                                                       ` Georg Bauhaus
2013-03-16 13:04                                                         ` Dmitry A. Kazakov
2013-03-16 16:10                                                           ` Georg Bauhaus
2013-03-16 17:47                                                             ` Dmitry A. Kazakov
2013-03-18 22:36                                                   ` Randy Brukardt
2013-03-19 10:14                                                     ` Dmitry A. Kazakov
2013-03-19 14:23                                                       ` Georg Bauhaus
2013-03-19 15:13                                                         ` Dmitry A. Kazakov
2013-03-19 16:52                                                           ` Georg Bauhaus
2013-03-19 17:31                                                             ` Dmitry A. Kazakov
2013-03-19 20:07                                                               ` J-P. Rosen
2013-03-19 20:45                                                                 ` Dmitry A. Kazakov
2013-03-19 21:59                                                                   ` J-P. Rosen
2013-03-20 10:04                                                                     ` Dmitry A. Kazakov
2013-03-20 11:01                                                                       ` J-P. Rosen
2013-03-20 13:21                                                                         ` Dmitry A. Kazakov
2013-03-20 23:31                                                                           ` Randy Brukardt
2013-03-21  9:08                                                                             ` Dmitry A. Kazakov
2013-03-22 10:23                                                                           ` J-P. Rosen
2013-03-22 14:54                                                                             ` Dmitry A. Kazakov
2013-03-22 22:18                                                                               ` J-P. Rosen
2013-03-22 23:05                                                                                 ` Shark8
2013-03-23  8:32                                                                                   ` Dmitry A. Kazakov
2013-03-23  8:14                                                                                 ` Dmitry A. Kazakov
2013-03-23  9:02                                                                                   ` J-P. Rosen
2013-03-23 10:19                                                                                     ` Dmitry A. Kazakov
2013-03-23 21:53                                                                                       ` J-P. Rosen
2013-03-24  8:17                                                                                         ` Dmitry A. Kazakov
2013-03-24  8:27                                                                                           ` J-P. Rosen
2013-03-24 13:01                                                                                             ` AdaMagica
2013-03-25  8:32                                                                                             ` Dmitry A. Kazakov
2013-03-25  9:19                                                                                               ` Georg Bauhaus
2013-03-25 10:08                                                                                                 ` Dmitry A. Kazakov
2013-03-19 21:37                                                       ` Randy Brukardt
2013-03-20  8:48                                                         ` Dmitry A. Kazakov
2013-03-14 16:22                                       ` Shark8
2013-03-14 17:08                                         ` Dmitry A. Kazakov
2013-03-13 22:34                               ` Robert A Duff
2013-03-14  9:09                                 ` Dmitry A. Kazakov
2013-03-14  9:27                                   ` Georg Bauhaus
2013-03-13 17:05                         ` Shark8
2013-03-13 17:45                           ` Simon Wright
2013-03-13 19:37                             ` Dmitry A. Kazakov
2013-03-13 19:54                               ` Simon Wright
2013-03-13 20:54                                 ` Dmitry A. Kazakov
2013-03-13 21:28                                   ` Simon Wright
2013-03-14  9:16                                     ` Dmitry A. Kazakov
2013-03-14 16:42                                       ` Simon Wright
2013-03-14 17:05                                         ` Dmitry A. Kazakov
2013-03-13 22:12                                   ` Robert A Duff
2013-03-13 21:47                                 ` Jeffrey Carter
2013-03-13 21:09                               ` Randy Brukardt
2013-03-13 22:48                                 ` Shark8
2013-03-14 22:01                                   ` Randy Brukardt
2013-03-15  3:27                                     ` Shark8
2013-03-15 21:05                                       ` Randy Brukardt
2013-03-15 21:46                                         ` Robert A Duff
2013-03-16  5:52                                           ` Shark8
2013-03-16  7:41                                             ` Dmitry A. Kazakov
2013-03-16 16:55                                               ` Shark8
2013-03-16 17:36                                                 ` Dmitry A. Kazakov
2013-03-16 21:51                                                   ` Shark8
2013-03-17  9:36                                                     ` Dmitry A. Kazakov
2013-03-18 23:13                                                       ` Randy Brukardt
2013-03-19  9:12                                                         ` Dmitry A. Kazakov
2013-03-19 21:19                                                           ` Randy Brukardt
2013-03-20 11:21                                                             ` Dmitry A. Kazakov
2013-03-20 23:57                                                               ` Randy Brukardt
2013-03-21 10:30                                                                 ` Dmitry A. Kazakov
2013-03-21 23:27                                                                   ` Randy Brukardt
2013-03-22 16:07                                                                     ` Dmitry A. Kazakov
2013-03-22 20:10                                                                       ` Shark8
2013-03-22 20:51                                                                         ` Dmitry A. Kazakov
2013-03-22 23:34                                                                           ` Robert A Duff
2013-03-23  8:41                                                                             ` Dmitry A. Kazakov
2013-03-23  2:29                                                                           ` Nasser M. Abbasi
2013-03-23  2:33                                                                       ` Randy Brukardt
2013-03-23  4:44                                                                         ` Shark8
2013-03-25 22:24                                                                           ` Randy Brukardt
2013-03-26  1:15                                                                             ` Shark8
2013-03-23  9:53                                                                         ` Dmitry A. Kazakov
2013-03-25 22:58                                                                           ` Randy Brukardt
2013-03-26 10:52                                                                             ` Dmitry A. Kazakov
2013-03-26 21:31                                                                               ` Randy Brukardt
2013-03-27  9:37                                                                                 ` Dmitry A. Kazakov
2013-03-27 19:42                                                                                   ` Randy Brukardt
2013-03-28 13:50                                                                                     ` Dmitry A. Kazakov
2013-03-28 21:55                                                                                       ` Randy Brukardt
2013-03-29 12:26                                                                                         ` Dmitry A. Kazakov
2013-03-30  0:49                                                                                           ` Randy Brukardt
2013-03-30  2:55                                                                                             ` Shark8
2013-04-01 23:43                                                                                               ` Messaging question [was: Is this expected behavior or not] Randy Brukardt
2013-03-30  9:20                                                                                             ` Is this expected behavior or not Dmitry A. Kazakov
2013-04-02  0:40                                                                                               ` Randy Brukardt
2013-04-02  8:44                                                                                                 ` Dmitry A. Kazakov
2013-04-02 21:54                                                                                                   ` Randy Brukardt
2013-04-03  8:54                                                                                                     ` Dmitry A. Kazakov
2013-04-04  0:04                                                                                                       ` Randy Brukardt
2013-04-04  8:26                                                                                                         ` Dmitry A. Kazakov
2013-04-04 20:31                                                                                                           ` Randy Brukardt
2013-04-05  9:57                                                                                                             ` Dmitry A. Kazakov
2013-04-05 12:45                                                                                                               ` Stefan.Lucks
2013-04-05 12:49                                                                                                                 ` Stefan.Lucks
2013-04-05 14:19                                                                                                                   ` Dmitry A. Kazakov
2013-04-05 14:44                                                                                                                     ` Stefan.Lucks
2013-04-05 16:11                                                                                                                       ` Dmitry A. Kazakov
2013-04-05 19:02                                                                                                                         ` Stefan.Lucks
2013-04-05 19:34                                                                                                                           ` Dmitry A. Kazakov
2013-04-05 20:23                                                                                                                             ` Stefan.Lucks
2013-04-06  7:39                                                                                                                               ` Dmitry A. Kazakov
2013-04-07 18:10                                                                                                                                 ` Stefan.Lucks
2013-04-07 18:23                                                                                                                                   ` Dmitry A. Kazakov
2013-04-05 20:38                                                                                                                             ` Stefan.Lucks
2013-04-05 14:36                                                                                                                 ` Dmitry A. Kazakov
2013-04-05 15:16                                                                                                                   ` Stefan.Lucks
2013-04-05 16:29                                                                                                                     ` Dmitry A. Kazakov
2013-04-05 19:55                                                                                                                       ` Stefan.Lucks [this message]
2013-04-06  1:45                                                                                                                         ` Randy Brukardt
2013-04-06  7:54                                                                                                                         ` Dmitry A. Kazakov
2013-04-07 18:17                                                                                                                           ` Stefan.Lucks
2013-04-07 18:28                                                                                                                             ` Dmitry A. Kazakov
2013-04-08  7:48                                                                                                                               ` Stefan.Lucks
2013-04-08  8:59                                                                                                                                 ` Dmitry A. Kazakov
2013-04-08 15:35                                                                                                                                   ` Stefan.Lucks
2013-04-08 19:08                                                                                                                                     ` Dmitry A. Kazakov
2013-04-09  7:18                                                                                                                                       ` Stefan.Lucks
2013-04-09  8:17                                                                                                                                         ` Dmitry A. Kazakov
2013-04-09 15:20                                                                                                                                           ` Stefan.Lucks
2013-04-09 16:15                                                                                                                                             ` Dmitry A. Kazakov
2013-04-09 22:59                                                                                                                                             ` Randy Brukardt
2013-04-09 22:57                                                                                                                                           ` Randy Brukardt
2013-04-10  7:30                                                                                                                                             ` Dmitry A. Kazakov
2013-04-10  8:00                                                                                                                                             ` Root_String'Class? (Was: Is this expected behavior or not) Jacob Sparre Andersen
2013-04-10 21:48                                                                                                                                               ` Randy Brukardt
2013-04-09 22:53                                                                                                                                     ` Is this expected behavior or not Randy Brukardt
2013-04-09 22:45                                                                                                                                   ` Randy Brukardt
2013-04-10  7:37                                                                                                                                     ` Dmitry A. Kazakov
2013-04-10 22:15                                                                                                                                       ` Randy Brukardt
2013-04-11  7:33                                                                                                                                         ` Dmitry A. Kazakov
2013-04-11 22:37                                                                                                                                           ` Randy Brukardt
2013-04-12  7:47                                                                                                                                             ` Dmitry A. Kazakov
2013-04-13  0:26                                                                                                                                               ` Randy Brukardt
2013-04-13  0:35                                                                                                                                               ` Randy Brukardt
2013-04-13  7:07                                                                                                                                                 ` Dmitry A. Kazakov
2013-04-06  1:38                                                                                                                       ` Randy Brukardt
2013-04-06  1:20                                                                                                               ` Randy Brukardt
2013-04-06  5:20                                                                                                                 ` Usefulness of OOP (was Is this expected behavior or not) J-P. Rosen
2013-04-06 10:31                                                                                                                   ` Dmitry A. Kazakov
2013-04-06 18:43                                                                                                                     ` Georg Bauhaus
2013-04-07  7:00                                                                                                                 ` Is this expected behavior or not Dmitry A. Kazakov
2013-04-09 23:24                                                                                                                   ` Randy Brukardt
2013-04-10  8:20                                                                                                                     ` Dmitry A. Kazakov
2013-04-10 22:07                                                                                                                       ` Randy Brukardt
2013-04-11  7:59                                                                                                                         ` Dmitry A. Kazakov
2013-04-11 11:10                                                                                                                           ` Georg Bauhaus
2013-04-11 13:49                                                                                                                           ` J-P. Rosen
2013-04-11 15:07                                                                                                                             ` Dmitry A. Kazakov
2013-04-12  4:39                                                                                                                               ` J-P. Rosen
2013-04-12  8:00                                                                                                                                 ` Dmitry A. Kazakov
2013-04-12  9:09                                                                                                                                   ` J-P. Rosen
2013-04-12 17:00                                                                                                                                     ` Jeffrey Carter
2013-04-11 23:02                                                                                                                           ` Randy Brukardt
2013-04-12  8:17                                                                                                                             ` Dmitry A. Kazakov
2013-04-12  9:41                                                                                                                               ` Georg Bauhaus
2013-04-12 11:46                                                                                                                                 ` Dmitry A. Kazakov
2013-04-13 17:38                                                                                                                                   ` Georg Bauhaus
2013-04-13  0:22                                                                                                                               ` Randy Brukardt
2013-04-13  6:49                                                                                                                                 ` Dmitry A. Kazakov
2013-04-16  1:41                                                                                                                                   ` Randy Brukardt
2013-04-16  8:03                                                                                                                                     ` Dmitry A. Kazakov
2013-04-16 22:57                                                                                                                                       ` Randy Brukardt
2013-04-17  7:18                                                                                                                                         ` Dmitry A. Kazakov
2013-04-17  9:23                                                                                                                                           ` Georg Bauhaus
2013-04-17  9:57                                                                                                                                             ` Dmitry A. Kazakov
2013-04-17 19:38                                                                                                                                               ` Georg Bauhaus
2013-04-18 11:52                                                                                                                                                 ` Dmitry A. Kazakov
2013-04-19  2:16                                                                                                                                                   ` Randy Brukardt
2013-04-19  7:39                                                                                                                                                     ` Dmitry A. Kazakov
2013-04-19  9:07                                                                                                                                                   ` Georg Bauhaus
2013-04-19  9:11                                                                                                                                                     ` Georg Bauhaus
2013-04-19 12:09                                                                                                                                                     ` Dmitry A. Kazakov
2013-04-19 22:14                                                                                                                                                       ` Randy Brukardt
2013-04-20  6:39                                                                                                                                                         ` Dmitry A. Kazakov
2013-03-19  0:38                                                       ` Shark8
2013-03-19  8:53                                                         ` Dmitry A. Kazakov
2013-03-16 20:45                                             ` Robert A Duff
2013-03-16  9:29                                           ` Georg Bauhaus
2013-03-16 20:49                                             ` Robert A Duff
2013-03-14 22:41                             ` Florian Weimer
2013-03-12 23:21           ` Randy Brukardt
2013-03-12 23:14       ` Randy Brukardt
2013-03-11 20:43   ` Anh Vo
2013-03-11 22:32     ` Randy Brukardt
2013-03-11 22:38     ` Robert A Duff
2013-03-12  9:17   ` Dmitry A. Kazakov
2013-03-13  0:10     ` Shark8
replies disabled

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