comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: class wide iterable (and indexable)
Date: Thu, 10 Jan 2019 09:53:09 +0100
Date: 2019-01-10T09:53:09+01:00	[thread overview]
Message-ID: <q1715k$1fou$1@gioia.aioe.org> (raw)
In-Reply-To: q160mb$863$1@franka.jacob-sparre.dk

On 2019-01-10 00:38, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:q159mg$1q6k$1@gioia.aioe.org...
>> On 2019-01-09 00:26, Randy Brukardt wrote:
>>
>>> But that's the point: there aren't any significant tagged classes here, just
>>> generic classes, because there is only one instance of each class (use of
>>> formal packages can't change that).
>>
>> This is what I do not understand. Instance of a class is a type. Do you
>> mean the depth of the hierarch,y probably? Because the number of sibling
>> instances is usually large.
> 
> But the siblings are incompatible with each other (different types, as you
> say).

Possibly.

> So there is no sharing that can be done between them other than that
> which comes directly from the generic unit itself.

If you design them specifically so, but why?

> That makes any interfaces
> (again, Ada interface feature) involved useless, as they're necessarily
> different than any other such interfaces, which means there isn't anything
> that you can do with them. So why have them at all?

You mean declaring an interface inside the generic?

>>> No, I argue that given that there is no realistic alternative (other than
>>> to abandon strong static typing by deriving everything from a common type,
>>> then store Object'Class).
>>
>> It cannot be Object'Class because that includes limited types etc. There
>> are lots of constraints on the elements depending on the container, like
>> ordering, hashes. These constraints must be spelled in the language, not
>> silently assumed. A named interface is a language to spell such
>> constraints. #1.
> 
> Making the elements much more expensive (because of the need to manage an
> expensive tag) than they otherwise would be. There's a lot of pushback on
> even making language-defined units tagged, because of overhead concerns.
> (Don't buy that myself, but that's the mindset.)

Yes, but this is another roadblock. Elements of containers should be 
externally tagged by-value types. That would eliminate the overhead.

> Anyway, #1 has to be part of the contract of the generic. Doesn't make sense
> otherwise. And packaging all of the contracts into a single entity has been
> tried in many ways (that's the original reason for formal packages, the
> so-called signature package) -- and it's always too inflexible. Best to just
> have the individual requirements clearly stated in the profile of the
> generic. (I'd have said "interface", meaning the concept, not the feature,
> but that gets too confusing.)

Sure. It is the same problem in both cases. The solution that would work 
for generics is exactly the interfaces (universal) I am talking about. 
Presently, it is only tagged contracts that are allowed (tagged type or 
Ada interface). And they work perfectly. If we introduced externally 
tagged contracts they would work out of the box just same. Ah, but we 
would not need generics then...

>> The instances must be further constrained by the user from his side. Just
>> like we declare an array type, it does not mean that it can hold any
>> elements from the class of definite types. #2.
>>
>> It seems that you mix constraints #1 with #2.
> 
> #1 has to be part of the contract of the generic; #2 clearly is not. Don't
> see any mixing there.

Then why interfaces are useless? Does it apply to #1 or #2.

>>> If there was a way to have a universal container interface independent of
>>> the element type (and have that be useful), then the concept would be a lot
>>> more useful. But that isn't possible in any Ada-like language and retain
>>> static typing.
>>
>> I do not understand why. Create an anonymous instance, clone the
>> hierarchy, constrain Element'Class to the concrete type T. Everything must
>> be done by the compiler in one step as it does for array types.
> 
> Well, separate array types are a mistake given that there are many
> implementations for a sequence.

There is more than one type of sequences. Sounds like a tautology already.

> It would be better for them to be a
> container just like all of the others. I.e. I'd make it harder to declare an
> array rather making it easier to declare a container. :-)

You make it regular. There is no reason why arrays and containers must 
be treated differently by the language.

> I discussed anonymous instances elsewhere; they do great damage to the Ada
> model that everything has a place and to readability.

But you cannot have safety if you are going to expose all dirty clothes. 
Separation of interface and implementation trumps everything. If an 
instance is for implementation reasons only it must be hidden.

BTW, names of generic instances induce a huge mess in practice. Nobody 
ever remember what name which instance in both directions. You see a 
name with half a dozen dots in it, and struggle to guess what the hell 
is this.

>> Right, this is our main conceptual disagreement. You want to stick to
>> generics though they have proven not working. The only alternative is
>> inheritance (advanced type system). If only one percent of mental efforts
>> were invested into the type system instead, we could have a different and
>> IMO better Ada today.
> 
> A different language, but it wouldn't be Ada.

Yes, it wouldn't be Ada 2012! (:-))

> There's no way it could be
> compatible enough, to do so would be to do great violence to that "advanced
> type system". Because most of the details of Ada types aren't advanced in
> any sense. :-)

We have discussed that many times. I see no reason why it should be 
incompatible. Except, maybe, for a few obscure cases with generics, 
nobody really cares about. There is no more than a half-dozen people in 
the world who know how these must work while they all disagree with each 
other... (:-))

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

  reply	other threads:[~2019-01-10  8:53 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-02 15:48 class wide iterable (and indexable) George Shapovalov
2019-01-02 17:39 ` Simon Wright
2019-01-02 18:11   ` George Shapovalov
2019-01-03  8:52     ` Simon Wright
2019-01-03  9:30       ` George Shapovalov
2019-01-03 16:45         ` Jeffrey R. Carter
2019-01-04  4:32       ` Shark8
2019-01-05  9:03         ` Randy Brukardt
2019-01-03 22:56     ` Randy Brukardt
2019-01-04  0:00       ` George Shapovalov
2019-01-04  8:43         ` Dmitry A. Kazakov
2019-01-04 12:20           ` George Shapovalov
2019-01-05 23:29             ` Jere
2019-01-05 23:50               ` Jere
2019-01-06  9:34                 ` George Shapovalov
2019-01-06 10:19                   ` Dmitry A. Kazakov
2019-01-06 11:30                     ` George Shapovalov
2019-01-06 12:45                       ` Dmitry A. Kazakov
2019-01-06 13:18                         ` George Shapovalov
2019-01-06 14:13                           ` Dmitry A. Kazakov
2019-01-06 16:33                             ` George Shapovalov
2019-01-06 18:29                               ` George Shapovalov
2019-01-06 20:32                                 ` Dmitry A. Kazakov
2019-01-06 21:47                                   ` George Shapovalov
2019-01-07  9:37                                     ` Niklas Holsti
2019-01-07 16:24                                       ` George Shapovalov
2019-01-06 20:18                               ` Dmitry A. Kazakov
2019-01-06 21:58                                 ` George Shapovalov
2019-01-07  8:28                                   ` Dmitry A. Kazakov
2019-01-05  9:21           ` Randy Brukardt
2019-01-05 10:07             ` Dmitry A. Kazakov
2019-01-05 18:17               ` George Shapovalov
2019-01-05 20:07                 ` Simon Wright
2019-01-05 20:41                   ` George Shapovalov
2019-01-07 21:07               ` Randy Brukardt
2019-01-08  9:51                 ` Dmitry A. Kazakov
2019-01-08 19:25                   ` Björn Lundin
2019-01-08 23:26                   ` Randy Brukardt
2019-01-09 17:06                     ` Dmitry A. Kazakov
2019-01-09 23:38                       ` Randy Brukardt
2019-01-10  8:53                         ` Dmitry A. Kazakov [this message]
2019-01-10 22:14                           ` Randy Brukardt
2019-01-11  9:09                             ` Dmitry A. Kazakov
2019-01-14 22:59                               ` Randy Brukardt
2019-01-15  9:34                                 ` Dmitry A. Kazakov
2019-01-18 15:48                                   ` Olivier Henley
2019-01-18 16:08                                     ` Dmitry A. Kazakov
2019-01-18 16:29                                       ` Olivier Henley
2019-01-18 16:54                                         ` Dmitry A. Kazakov
2019-01-18 17:31                                           ` Olivier Henley
2019-01-18 18:51                                             ` Shark8
2019-01-18 20:09                                             ` Dmitry A. Kazakov
2019-01-21 23:15                                     ` Randy Brukardt
2019-01-22  8:56                                       ` Dmitry A. Kazakov
2019-01-22 22:00                                         ` Randy Brukardt
2019-01-23  8:14                                           ` Dmitry A. Kazakov
2019-01-22 17:04                                       ` Jeffrey R. Carter
2019-01-22 22:02                                         ` Randy Brukardt
2019-01-23 18:00                                           ` Jeffrey R. Carter
2019-01-23 20:14                                           ` Shark8
2019-01-23 22:47                                             ` Randy Brukardt
2019-01-24 17:11                                               ` Dmitry A. Kazakov
2019-01-28 15:54                                               ` Shark8
2019-01-28 17:23                                                 ` Dmitry A. Kazakov
2019-01-08 18:32                 ` G. B.
2019-01-05 17:05             ` Jeffrey R. Carter
2019-01-05 20:18               ` Dmitry A. Kazakov
2019-01-05 21:09               ` Shark8
2019-01-06 10:11                 ` Jeffrey R. Carter
2019-01-05 20:46             ` Shark8
2019-01-06  9:43               ` Dmitry A. Kazakov
2019-01-26 22:11 ` George Shapovalov
2019-01-26 22:14   ` George Shapovalov
  -- strict thread matches above, loose matches on Subject: below --
2019-01-29  7:45 Randy Brukardt
2019-01-29 19:34 ` Niklas Holsti
2019-01-29 20:26   ` Dmitry A. Kazakov
replies disabled

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