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!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!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: 09 Sep 2006 10:49:43 -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 1157813383 13665 192.74.137.71 (9 Sep 2006 14:49:43 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 9 Sep 2006 14:49:43 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news2.google.com comp.lang.ada:6535 Date: 2006-09-09T10:49:43-04:00 List-Id: Maciej Sobczak writes: > Robert A Duff wrote: > > >> 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. > > Is it also tagged? Do you want it to be? Everything should be tagged. There should be no "tagged" keyword. But the compiler should not store the tag with every object, by default. Tags are only needed for class-wide objects, and perhaps aliased objects. >...Or maybe there should be a > special case for Integer (and its every subtype), so that it's > semantically in Ordered'Class without being syntactically tagged? Special-casing predefined things is usually a mistake. Note that the rule saying 'Class only works for tagged types is not necessary, and was not present in earlier versions of Ada 9X. In fact, universal_integer is really root_integer'Class, conceptually. Too bad you can't mention its name in a program. > Is it really in the spirit of Ada? No, apparently not. > Integer is not only Ordered. It's also Summable, Subtractable, > Multipliable, Divideable, Powerable, Incrementable, Decrementable, > Comparable, Copyable, Assignable, Imageable and even Aspect_Clauseable, > not mentioning Can_Be_Used_As_Array_Index. And it has some others as > well. > And all this is very important, since there might be other types that > share only some of these properties but not others and surely we don't > want our Container_Of_Incrementable_And_Divideable_And_Comparable to > contain something that isn't, right? > > (sorry if any of the above is not proper English) > > ;-) I understood it. Part of the problem (in most languages, including Ada) with all of the above classes is that you have to decide up front. It would be useful to be able to say "type T inherits from Mungable" without modifying the source code for T or Mungable. > And switching back to serious, I somehow don't like languages that try > to apply object-orientedness to absolutely everything. Why? Note that making everything tagged, and having a root Object type in the hierarchy doesn't really make everything OO. OO-ness really comes from 'Class, mainly. >... In C++ the fact > that int is ordered does not require that it relates to some Ordered > class. Such properties - if needed - can be expressed in other ways. > > > > A hierarchy with Object at the top would be a Good Thing, IMHO. Trees > > are more aesthetically pleasing than forests. > > Opinions vary on this subject. :-) Indeed. ;-) Of course, my comment about trees is somewhat bugus if multiple inheritance is allowed. > > 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); > > Yes, that would be fine. - Bob