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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,91276ec2ea911d3f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Generic procedures and their parameters Date: 06 Sep 2006 09:11:12 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1157548272 767 192.74.137.71 (6 Sep 2006 13:11:12 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 6 Sep 2006 13:11:12 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news2.google.com comp.lang.ada:6472 Date: 2006-09-06T09:11:12-04:00 List-Id: Maciej Sobczak writes: > But then, you would need to have even such fundamental things like > Integer belong to Ordered'Class. It's a shaky ground. Why is that shaky? Integer IS ordered. > > Regarding Array_Type being implied, it is not. You can have any number of > > array types based on exactly same combination of index and element types. > > These types will be different types: > > type I is ...; > > type E is ...; > > type Array1 is array (I range <>) of E; > > type Array2 is array (I range <>) of E; > > > The types Array1 and Array2 are distinct types. > > And now I see. I'm still having troubles with the fact that > "granularity" of type system in Ada can be much smaller than what can be > achieved with structural differences only. It's a good thing that Ada allows Array1 and Array2 above to be different types. But sometimes, structural typing would be better. In fact, Ada has moved a bit in that direction -- anonymous access types use structural typing, more or less. > > The next step would be getting "<" from the element type, > > which would eliminate a need to have Sort generic. > > No, I disagree. There is a place for generic subprograms, otherwise we'd > have everything in a single hierarchy with Object at the top. It's not a > coincidence that "other languages" drift towards supporting generics, > even if they already had such single-rooted hierarchies. A hierarchy with Object at the top would be a Good Thing, IMHO. Trees are more aesthetically pleasing than forests. But you're right that you still need some sort of generic facility, so you can have strongly typed containers. But I think perhaps we should have generic types (i.e. parameterized types) rather than generic packages. That's what discriminants do, but they're severely limited. It would make sense to have a discriminant that is a type, so you could say: My_Sequence: Sequence(Element => Integer) := (1, 2, 3); - Bob