comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Ada.Locales pseudo-string types
Date: Thu, 09 Aug 2012 11:31:44 +0300
Date: 2012-08-09T11:31:44+03:00	[thread overview]
Message-ID: <a8hargFl1kU1@mid.individual.net> (raw)
In-Reply-To: <1oel9yro6j0vj.1a64kz67quj9u$.dlg@40tude.net>

On 12-08-09 10:48 , Dmitry A. Kazakov wrote:
> On Wed, 08 Aug 2012 17:01:23 +0300, Niklas Holsti wrote:
> 
>> On 12-08-08 14:59 , Dmitry A. Kazakov wrote:
> 
>>> BTW, if you go that far you should also allow conversions between any array
>>> types of convertible elements. E.g. between arrays of floats and arrays of
>>> integers etc.
>>
>> Well, for explicit value conversions, why not? But I don't think that
>> there is significant need for such conversions on the array level.
> 
> I needed to convert array of access types in some cases. But I agree that
> there is no significant need in array conversion, in any array conversion,
> I would add. Don't we consider conversions bad, in Ada? If so, we should
> rather eliminate cases where conversions are needed, rather than inventing
> more and more sophisticated ways of conversion.

I think that conversions are the logically right thing in some cases,
while more inheritance (which I assume is your aim) is better in other
cases. I would not like to reduce the conversion abilities of Ada.

>> What I have sometimes found annoying is that operations on arrays of a
>> parent type cannot easily be applied to arrays of a derived type.
>> For example:
>>
>>    type Parent is (A, B, C);
>>    type Parent_Arr is array (Positive range <>) of Parent;
>>
>>    procedure Print (Item : in Parent_Arr)
>>    ...
>>    end Print;
>>
>>    type Child is new Parent;
>>    type Child_Arr is array (Positive range <>) of Child;
> 
> If arrays had classes you could inherit the Parent's interface which would
> bring Print with it.

It is not clear to me how that would work, in detail. Either one would
have to override all the operations for Child_Arr, to substitude Parent
with Child, or there would have to be some implicit rules for such
substitutions, which would in effect establish the same implicit
relationship between Child_Arr and Parent_Arr as I feel already exists.

>> The operation Print on Parent_Arr is not inherited by Child_Arr,
> 
> Why should it? Child_Arr is unrelated to Parent.

It is just a feeling, and sometimes a practical need. Surely Child_Arr
is in some sense related to Parent_Arr, since Child is related to
Parent, and the same type construction (array) is used in both?

If a Child is-a Parent, in the sense that primitive operations for
Parents are also available (inherited) for Children, why are not
operations on collections of Parents available for collections of
Children? A collection (array) of Children is-a collection of Parents.

(This relationship could be easier to see and implement if Ada had a
"sequence" type construction in addition to the "array" type
construction, because then we would not have to consider the possible
difference in the index types of Child_Arr and Parent_Arr. That is, if a
list of elements of type T could be defined as "sequence of T" without
having to choose a specific type and range to index the sequence.)

> Somewhere in its
> declaration Child_Arr must say "new Parent" or "and Parent." Such type
> relationships must be manifested, not implied.

I'm not sure that making the relation manifest in that way is important.
I think that an Ada-derived language could be defined that would let
Child_Arr inherit Print from Parent_Arr, without requiring this manifest
relation in the syntax. Other considerations (readability, reliability)
would determine the decision.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .



  reply	other threads:[~2012-08-13  8:47 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-06 16:45 Ada.Locales pseudo-string types Marius Amado-Alves
2012-08-06 17:10 ` Marius Amado-Alves
2012-08-06 19:15   ` J-P. Rosen
2012-08-06 19:34     ` Simon Wright
2012-08-06 20:07       ` Marius Amado-Alves
2012-08-06 20:57         ` Simon Wright
2012-08-06 21:09           ` Vasiliy Molostov
2012-08-06 23:07             ` Adam Beneschan
2012-08-06 23:23               ` Vasiliy Molostov
2012-08-06 23:46                 ` Adam Beneschan
2012-08-07  1:17                   ` Vasiliy Molostov
2012-08-07  7:20               ` Dmitry A. Kazakov
2012-08-07  7:43               ` Jacob Sparre Andersen
2012-08-09 20:47                 ` Randy Brukardt
2012-08-07  8:44               ` Marius Amado-Alves
2012-08-07 13:14                 ` Marius Amado-Alves
2012-08-07 15:42                   ` Adam Beneschan
2012-08-07 18:22                     ` Marius Amado-Alves
2012-08-07 20:10                       ` Adam Beneschan
2012-08-07 20:42                         ` Marius Amado-Alves
2012-08-07 21:38                           ` Adam Beneschan
2012-08-08  7:04                           ` Niklas Holsti
2012-08-08  7:18                             ` Dmitry A. Kazakov
2012-08-08  7:37                               ` Niklas Holsti
2012-08-08  8:09                                 ` Dmitry A. Kazakov
2012-08-08 11:14                                   ` Niklas Holsti
2012-08-08 11:59                                     ` Dmitry A. Kazakov
2012-08-08 14:01                                       ` Niklas Holsti
2012-08-09  7:48                                         ` Dmitry A. Kazakov
2012-08-09  8:31                                           ` Niklas Holsti [this message]
2012-08-09 12:17                                             ` Dmitry A. Kazakov
2012-08-09 15:25                                               ` Niklas Holsti
2012-08-09 16:43                                                 ` Dmitry A. Kazakov
2012-08-08  8:28                                 ` J-P. Rosen
2012-08-08 11:35                                   ` Niklas Holsti
2012-08-08 14:05                                     ` Georg Bauhaus
2012-08-08  7:32                             ` J-P. Rosen
2012-08-08  8:17                               ` Niklas Holsti
2012-08-08  8:33                                 ` J-P. Rosen
2012-08-08 11:44                                   ` Niklas Holsti
2012-08-09 21:00                                   ` Randy Brukardt
2012-08-08  8:35                                 ` Dmitry A. Kazakov
2012-08-08  9:32                                   ` Marius Amado-Alves
2012-08-08 10:11                                     ` Dmitry A. Kazakov
2012-08-08 11:28                                       ` Marius Amado-Alves
2012-08-08 11:30                                         ` Marius Amado-Alves
2012-08-08 11:35                                       ` Marius Amado-Alves
2012-08-08 12:24                                         ` Dmitry A. Kazakov
2012-08-08 11:52                                   ` Niklas Holsti
2012-08-08 13:21                                     ` Dmitry A. Kazakov
2012-08-08  9:07                             ` Marius Amado-Alves
2012-08-07 20:43                         ` Marius Amado-Alves
2012-08-07 21:59                   ` Robert A Duff
2012-08-07 22:19                     ` Adam Beneschan
2012-08-08  0:37                       ` Robert A Duff
2012-08-07 15:26                 ` Adam Beneschan
2012-08-07 18:07                   ` Marius Amado-Alves
2012-08-07 17:51       ` Simon Wright
2012-08-06 20:00     ` Marius Amado-Alves
2012-08-06 19:49   ` Jacob Sparre Andersen
2012-08-06 20:11     ` Marius Amado-Alves
2012-08-06 17:37 ` Michael Rohan
2012-08-06 18:23   ` Marius Amado-Alves
2012-08-06 19:36     ` Michael Rohan
2012-08-09 21:15   ` Randy Brukardt
2012-08-07  5:57 ` Jeffrey R. Carter
2012-08-07 15:46   ` Adam Beneschan
2012-08-07 17:51     ` Jeffrey R. Carter
2012-08-09 21:17       ` Randy Brukardt
replies disabled

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