From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: class wide iterable (and indexable) Date: Tue, 8 Jan 2019 17:26:17 -0600 Organization: JSA Research & Innovation Message-ID: References: <2a6929c5-72fa-4d84-953a-44ea4597ab38@googlegroups.com> Injection-Date: Tue, 8 Jan 2019 23:26:18 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="24238"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 X-RFC2646: Format=Flowed; Response Xref: reader01.eternal-september.org comp.lang.ada:55247 Date: 2019-01-08T17:26:17-06:00 List-Id: "Dmitry A. Kazakov" wrote in message news:q11rqe$dtn$1@gioia.aioe.org... > On 2019-01-07 22:07, Randy Brukardt wrote: .... >>> I don't understand this. Usually I have dozens of instantiations of the >>> same generics with different actual parameters. >> >> Right, but all of those are *different* interfaces because they have >> *different* generic parameters. You can't mix those types in any useful >> way, >> because you almost always have the generic parameter type(s) involved. > > Of course I can mix them. Generics are mixed by passing to other generics: > > generic > with package X is new P (<>); > package Mixer is ... Sure but this has nothing whatsoever to do with interfaces (the Ada feature, as opposed to the concept). You can do this with a typical untagged private type, and the effects will be essentially the same. > The body is valid for all instances of P. And we still have not > specialization of generics. So the set of instances cannot be constrained > later. > > Though, I don't see how it is important to mix or not to mix instances to > the question which method of building a class is better. Tagged classes > are infinitely better than generic classes. 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). There's no point in having more (unless you like adding complication for the sake for doing that). >> For instance, for the containers, an interface would have to contain the >> element type. But that substantially limits reuse, because almost every >> container instance would have a different element type. You can't even >> pass >> just the interface into a generic because you wouldn't be able to call >> the >> primitives without knowing the element type. To make such a reuse >> possible >> you'd have to pass so many parameters that you are typing instantiations >> for >> days. And then the compilation time also would be days. You'd have to be >> slightly mad to even try it. :-) > > I don't see your point. You argue that generic-based design of containers > is bad. Of course it is bad. 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). And that leads to little value for tagged classes, and essentially none for interfaces. 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. (If you're willing to completely abandon static typing, then everything is possible.) ... > No, Ada is all OOP as we do > > type I is new Natural; -- Interface There's no interface (again, I'm only talking about the Ada feature, not some concept) here, and no OOP (again, in an Ada sense). > instead of > > type I is private; -- Nobody knows what > function "+" (Left, Right : I) return I; > function "-" (Left, Right : I) return I; > function "*" (Left, Right : I) return I; > function "/" (Left, Right : I) return I; > function "0" return I; > function "1" return I; > function "2" return I; > ... Well, the proposed BigNum packages look just like this, and I've written packages like this. (Besides, I note that we started with a BigNum interface -- which I tried to be in favor of -- and it was removed because of performance concerns. The place where interfaces actually have some use is where you have an abstraction with a variety of representations and uses -- such as strings or math. That's rare, though, and pretty much only happens in the language-defined libraries.) ... >> And you talk about this a lot, so I don't know what it is that you think >> you >> gain with interfaces that you wouldn't have with a normal record type and >> primitive operations. > > Give me tagged types to freely inherit from and I promise to never use > interfaces [*] again! (:-)) Which makes sense to me, since the primary benefit of inherited types is implementation reuse. Which interfaces don't allow. I'd surely support this position, but I think it is impractical to implement (as well as define properly rules for). ... >>> ---------------------- >>> * GNAT is awfully slow when compiling specifically generic >>> instantiations, >>> and I have lots of them. The more I have, the more I hate them. >> >> This is the point where I'd usually suggest trying a different compiler. >> :-) > > And I usually point out that without Linux/VxWorks support and targets > like ARM there is no chance. Love to do those sorts of things. Know anyone with lots of money that they don't know what to do with? (To expand the cross-platform support of Janus/Ada just takes money, as I would need to hire people to seriously be able to support that. The front-end is designed for such support, especially since targetted the U2200 for Unisys [if we can handle a 36-bit machine, we can handle anything :-)]) ... >> OTOH, I don't want you to >> try Janus/Ada (even on the code that don't use actual interfaces), 'cause >> the way you use generics would inevitably break stuff and I'd hate to >> have >> to debug code like that. :-) :-) > > I would gladly use Janus/Ada or ObjectAda if I could. I was a happy user > of the latter long ago. Unfortunately cross-platformity is a requirement > in these days. Understood. As you know, that costs $$$, and there aren't enough of those to go around. Randy.