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: Wed, 27 Mar 2013 10:37:50 +0100
Date: 2013-03-27T10:37:50+01:00	[thread overview]
Message-ID: <wdlyfbnwcnp7.10c9btwjmpm7j.dlg@40tude.net> (raw)
In-Reply-To: kit43q$mj1$1@munin.nbi.dk

On Tue, 26 Mar 2013 16:31:35 -0500, Randy Brukardt wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
> news:1u72u7h5j4jg3$.wlxmaltyzqik.dlg@40tude.net...
>> On Mon, 25 Mar 2013 17:58:26 -0500, Randy Brukardt wrote:
>>
>>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
>>> news:a96esjwiniqy$.op3wh7x9wrsl.dlg@40tude.net...
>>>> On Fri, 22 Mar 2013 21:33:02 -0500, Randy Brukardt wrote:
>>> ...
>>>>> That doesn't necessarily mean copying of the data. If the designer
>>>>> of the abstraction, have put in enough smarts to share 
>>>>> representations --
>>>>> after all,
>>>>
>>>> You should break your mental block. No shared representation, I want
>>>> different representations for different string types.
>>>
>>> I was talking about sharing representations of *different* objects of the
>>> same string type (for instance, a string variable and a slice of that
>>> variable - that case, sharing the data might be preferred to copying it).
>>
>> OK, the representation would be for type-specific string objects:
>>
>>   bounds + pointer
>>
>> and for class-wide string objects:
>>
>>   tag + bounds + pointer
> 
> Sure, but irrelevant. The question is whether slicing copies the data or 
> not. If it is a new object, the data must be copied logically,

No, logically it is a referential object.

> but my point 
> was that it would be possible for an abstraction to defer actually making a 
> copy until an assignment is actually done. It's still a copy.

Exactly the reverse, an implementation could be allowed to use a copy if
that is consistent with the semantics of the slice being a reference.

But regardless of the semantics, why this representation should not work?

>>> Unifying old junk it's possible without serious breakage of existing 
>>> code, which is intolerable.
>>
>> Why is it junk? There is nothing wrong with String, Wide_String,
>> Wide_Wide_String. They should stay.
> 
> They're junk because they can't be unified without serious breakage of 
> existing code.

A common ancestor would not break existing code. An ad-hoc ancestor could
not do it even theoretically, because it is limited to the context where
the ancestor is visible.

>>> And dispatching is incompatible with untagged types, simply because Ada 
>>> 83 got inheritance horribly wrong, and we're stuck with that.
>>
>> I disagree. It seems fully compatible with Ada 83 because T'Class would be
>> a distinct type with objects of that type. It is orthogonal to
>> Ada-subtypes. You will not dispatch on Positive vs. Integer, these will
>> reman specific [sub]types. In order to dispatch you will need a class-wide
>> object of the type Integer'Class (which will be strictly same as
>> Positive'Class, except, possibly, the constraint). That object will have
>> the representation tag + value. For Integer and Positive objects nothing
>> changes. We might consider redefining some existing operations to become
>> class-wide in some arguments, but that is another story.
> 
> You missed the point altogether. You can't dispatch in general on untagged 
> types because overriding operations may have different modes and subtypes 
> for the parameters. So what *is* the profile of the operation for T'Class, 
> and how can it work?
> 
> Consider:
> 
>      Type Int is range 1 .. 10;
>      procedure Op (A, B : in Int);
> 
>      Type Der is new Int;

This is not derivation within the class, it is a "type-cloning." Type
cloning creates a new class and new a type (all types up the hierarchy). We
need some syntax to indicate the difference.

   type Der is new Int <whatever>;

It is unfortunate that tagged types reused "is new" for a purpose
completely different from type cloning.

Moreover, it is highly desired to that cloning were available for tagged
types as well:

   package Original is new Ada.Containers.Vectors ...;
   type Clone is new Original.Vector; -- Cloning, not extending!

Now, I have to hierarchies of Vector, not very useful in this particular
case, because of missing helper types, but anyway.

>      overriding
>      procedure Op (A : in out Der; B : in Der);

This is not an overriding since the mode is different.

>      Obj : Int'Class := Der'(1);
>      Op (A => 1, B => Obj); -- Legal??

MD is not fully implemented in Ada, but anyway, presuming that Op is a
multi-method, that the mode is "in" and that 1 is Universal_Integer (is
it?), the above is illegal because Op is not a method of
Universal_Integer'Class. You would have to write it as:

   Op (A => Der'(1), B => Obj);  -- Same tags
   Op (A => Int'(1), B => Obj);  -- Different tags, Constraint_Error

Multi-methods (a special case of MD) is another and long story. They should
be properly supported in the end.

> And if you say that Der cannot override Op this way, you're now incompatible 
> with Ada 83- Ada 2012.

I want to preserve and extend type-cloning.
 
>>>>>> You have a very specific use case in mind, namely containers. There is a
>>>>>> whole world outside that, for which what you said is untrue, e.g. for
>>>>>> smart pointers. The thing not only exposes access, it also exposes the
>>>>>> target type.
>>>>>
>>>>> You have to expose the target type in order to have strong typing. How
>>>>> could you hide it and still make type checks?
>>>>
>>>> Why should target type be public?
>>>
>>> How do you enforce strong typing without that being the case? If you don't
>>> know what the target is, how do you determine how the resulting object can
>>> be used?
>>
>> Target and handle types usually implement some public interface. E.g.
>>
>>   type File_Access is limited interface;
>>   procedure Write (File : in out File_Access; Data : ...) is abstract;
>>   ...
>>
>> Somewhere else
>>
>>   type File_Descriptor is ... limited ... and File_Access ...;
>>
>> Somewhere else
>>
>>   type File_Handle is ... and File_Access ...;
> 
> An interface can't have "..." as the parameter type for Write; there has to 
> be something there.

   procedure Write (File : in out File_Access; Data : Stream_Element_Array)
      is abstract;

> And that's the target type! Say again how it is that you 
> are not exposing this type??

The target is File. I would gladly have MD and a hierarchy for the second
parameter, but that is another story for now.

>>>>> That's my point about static analysis. Such a tool should be able to prove
>>>>> that the majority of run-time checks can't happen, and give you a list of
>>>>> those remaining.
>>>>
>>>> I don't need any list. Should I send it to my customers? I need the
>>>> program fail to compile when writing analogue input.
>>>
>>> Treat the list as failures if you must, and insist that it be empty 
>>> before shipping.
>>
>> So, I need an AI system to parse compiler messages (of various vendors) on
>> top?
> 
> Huh? Why would you "parse" them?

Because whether a message is relevant to the choice if the program were OK
to deploy depends now on the message content. The language does not help me
anymore to indicate it as a bug.

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


  reply	other threads:[~2013-03-27  9:37 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 [this message]
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
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