comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Is this expected behavior or not
Date: Tue, 2 Apr 2013 10:44:07 +0200
Date: 2013-04-02T10:44:07+02:00	[thread overview]
Message-ID: <3gv2jwc95otm.pl2aahsh9ox8.dlg@40tude.net> (raw)
In-Reply-To: kjd9ec$6lr$1@munin.nbi.dk

On Mon, 1 Apr 2013 19:40:42 -0500, Randy Brukardt wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
> news:1gnmajx2fdjju.1bo28xwmzt1nr.dlg@40tude.net...
> ....
>> The point is that whether you create a totally new string hierarchy or
>> create one for already existing string types, you will have the issue with
>> "&" (and any other operation with more than one argument/result of string
>> type). That is *independent* on whatever Ada did or not before. It is in
>> the nature of a multi-method, which "&" is. If you want a hierarchy of
>> strings you *must* face this problem.
> 
> No you don't. There are no language-defined multi-methods. String & String = 
> String is not a multi-method.

Once String becomes member of a class it is. For the operation "&" there
exist only two possibilities, Either it is a primitive operation of the
class and so a multi-method, or else it is declared individually on each
member of the class in separate packages (somewhere after the freezing
point). The later variant is so silly that I don't even consider it.

> You, the user, can define such operations, of 
> course, but then you have the deal with the consequences. Generally, it's 
> best if you don't do that.

What is the use of a string type without operations? 

>>>> The model of Ada 95 tagged types provides a class with shared
>>>> representations. This need to be augmented for the case when
>>>> representations has to be different. Note that this was partially done when
>>>> Java interfaces were added in Ada 2005. Java interface is a type without
>>>> any representation, so there is nothing to inherit from, except for a slot
>>>> for the type tag. Drop that slot, and you will have a workable model for
>>>> building classes of scalar types and arrays.
>>>
>>> I don't know how one could implement "interfaces" without a tag.
>>
>> You have the tag in the representation of untagged'Class. You don't have 
>> it in the representation of untagged.
> 
> Doesn't work, as I've previously explained.

You said that it would not fit into Ada 83 derived types model. I answered
that it never considered within that model. The model to augment is Ada 95
tagged types.

> You have to be able to inherit 
> implementation of operations, for all types.

It is already not so. See Ada 95 abstract primitive operations and
operations dispatching in the result. They are NOT inherited. The
programmer is asked to override them, because the compiler has no idea how
to implement them.

> And there exist plenty of Ada 
> types for which copying is not allowed.

No problem. See above. All primitive operation will be inherited abstract
if the representation is not inherited and no [user-defined] conversion
defined (e.g. for a by-reference type).

> The only way to implement those is 
> via some sort of dispatching, and the need poisons the possibility of 
> omitting tags, even for "specific" operations.

I don't understand where you get this. The model is exactly the model of
tagged types, but without specific objects required to keep the tag. The
only thing it influences is view conversions between T and T'Class. Nothing
else is changed.
 
> The type conversions are view conversions, and they never make copies.

View conversions will be kept for tagged types and not introduced for
untagged ones.

> That 
> forces the representation to be compatible. You could change that for 
> by-copy types (although that would have run-time compatibility issues for 
> controlled objects),

Controlled objects are tagged, hence no change here.

> but you can't change that for types that have no copy 
> operation (like tasks and protected objects). So how to do you implement 
> them? Array of task is an untagged type, too, and it certainly should be 
> able to use 'Class.

Sure. T'Class will be a referential object when T is untagged by-reference
type. It will consist of the type tag and a *pointer* to the specific
object (not much different from 4.1.5), and from view conversions ether,
though formally a new object.

When T is by-copy, T'Class is the type tag + a copy of T.

>> I don't ban inheritance of the representation. I want to be able not to do
>> it when I don't need it, e.g. for character and string types.
> 
> But it's not that easy. If you have an array of tasks:
> 
>     type Foo (1 .. 10) of Some_Task with Component_Size => 32;
> 
> and you derive another array of tasks from it:
> 
>    type New_Foo is new Foo with Component_Size => 64;
> 
> This is legal, and you have different representations.

Irrelevant. Ada 83 derivation (cloning) is orthogonal to Ada 95 extension
model. We are talking about the later.

>>> It really kills the entire idea.
>>
>> No, IF String inherited the representation of Wide_Wide_String, THAT would
>> kill the idea.
>>
>> The whole idea is not to inherit irrelevant representations!
> 
> I don't see the problem here; if Root_String is an abstract tagged type,

Java interfaces will not work for characters/strings. No need even to try
it.

>> The bottom line is, I regard Ada 83 construct "type S is new T;" as very
>> useful, and wished it be valid with all specific types without silly
>> exceptions Ada 95 made for tagged types.
> 
> Fair enough. I regard "type S is new T;" as a junk piece of syntax that was 
> inherited from Ada 83, and should never be used. We completely disagree on 
> this one, and there really is nothing worth talking about.
> 
> You previously asked about:
> 
>     type Velocity is new Float;
> 
> That would get you a repremand if you worked for me. You never, ever use the 
> types in Standard (because they're not necessarily portable to other 
> compilers). You derive types based on your actual application requirements:
> 
>    type Velocity is digits 5 range -1.0E+10 .. 1.0E+10;

This is a bad design pattern because it refers to some magic numbers spread
all over the source code, a huge maintenance problem, potentially. The
proper pattern would be:

   type Measurement is digits 5 range -1.0E+10 .. 1.0E+10;
   ...
   type Velocity is new Measurement;
   type Acceleration is new Measurement;
   ...

>>> Because you need operations that work on every object,
>>> copyable or not. Remember, there are no type conversions between types in
>>> different hierarchies.
>>
>> And, this is what different hierarchies are for.
> 
> For what? To make it impossible to pass integers to Text_IO, or to use them 
> to instantiation Text_IO?

It is in the same generic formal class, thus instantiation is possible.

You are confusing generic classes, and classes induced by cloning, and
classes induced by interface inheritance. They are not same.

There is an infinite number of means by which some types could be lumped
into a class. Class is no more than a set of types. E.g. all types which
declarations start at the source code line 123 is a class. That does not
make them possible or not to be used in Text_IO instantiation. That would
be some other class.

>>>> But they are still the same
>>>> hierarchy. You need some fundamental operation which tells that a type
>>>> breaks off the hierarchy.
>>>
>>> Yes, of course all containers ought to be members of the same hierarchy. 
>>> How else would you create generic algorithms?
>>
>> Easily. Cloning borrows all operations. Define algorithm on the original
>> type. Then clone it. Done!
> 
> But you have cloned nothing.

I did types, literals, operations.

> Either you have a conversion to the original 
> type, in which case they belong to the same hierarchy.

This is a possible way to implement cloning. This is not the semantics of.
The semantics is that there is a new set of types, values and operations
with the properties of the original. Nothing more.

> A string class with a mixed & is nonsense. (I think the String & Character 
> in Ada 83 was nonsense, but it's not a problem here.)

It would be interesting to learn how many c.l.a. readers share such an
extreme view.

To me "&" is one of the most important requirements on string class design.
It is also a good test for the language type system maturity.
 
> The only & is String & String = String, and so on for all types.

Totally useless, IMO.

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



  reply	other threads:[~2013-04-02  8:44 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 [this message]
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
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