comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Generic procedures and their parameters
Date: 09 Sep 2006 10:49:43 -0400
Date: 2006-09-09T10:49:43-04:00	[thread overview]
Message-ID: <wcczmd93xiw.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: edml3e$pnf$1@sunnews.cern.ch

Maciej Sobczak <no.spam@no.spam.com> 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



  parent reply	other threads:[~2006-09-09 14:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-06  8:51 Generic procedures and their parameters Maciej Sobczak
2006-09-06  9:43 ` Dmitry A. Kazakov
2006-09-06 12:36   ` Maciej Sobczak
2006-09-06 13:11     ` Robert A Duff
2006-09-06 14:14       ` Maciej Sobczak
2006-09-06 15:09         ` Dmitry A. Kazakov
2006-09-06 16:35           ` Georg Bauhaus
2006-09-07  7:32             ` Dmitry A. Kazakov
2006-09-07  6:48               ` Georg Bauhaus
2006-09-07 10:19                 ` Dmitry A. Kazakov
2006-09-08  9:11           ` Maciej Sobczak
2006-09-08 10:19             ` Dmitry A. Kazakov
2006-09-09 14:49         ` Robert A Duff [this message]
2006-09-09 15:34           ` Dmitry A. Kazakov
2006-09-09 23:26           ` Jeffrey R. Carter
2006-09-10 11:49             ` Robert A Duff
2006-09-10 19:43               ` Jeffrey R. Carter
2006-09-06 13:02   ` Robert A Duff
2006-09-06 14:09     ` Dmitry A. Kazakov
2006-09-08  3:35   ` Randy Brukardt
2006-09-08  7:21     ` Dmitry A. Kazakov
2006-09-09  1:29       ` Randy Brukardt
2006-09-09  7:14         ` Dmitry A. Kazakov
2006-09-09 14:32         ` Robert A Duff
2006-09-06 12:56 ` Robert A Duff
2006-09-07  2:47 ` Steve
2006-09-07  7:47   ` 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