comp.lang.ada
 help / color / mirror / Atom feed
From: "James S. Rogers" <jimmaureenrogers@worldnet.att.net>
Subject: Re: point by point advantages of Ada
Date: Tue, 07 Jan 2003 01:35:26 GMT
Date: 2003-01-07T01:35:26+00:00	[thread overview]
Message-ID: <y9qS9.98932$hK4.8017421@bgtnsc05-news.ops.worldnet.att.net> (raw)
In-Reply-To: 24oS9.30853$p_6.2594702@bgtnsc04-news.ops.worldnet.att.net


"David Thompson" <david.thompson1@worldnet.att.net> wrote in message
news:24oS9.30853$p_6.2594702@bgtnsc04-news.ops.worldnet.att.net...
> James S. Rogers <jimmaureenrogers@worldnet.att.net> wrote :
> ...
> > The solution for such a need is basically the same in both C++ and Ada.
> > C++ provides no multiple dispatch capability. You must make such a
> > function static, not virtual. In Ada you do the same thing. You simply
> > define the procedure(s) taking more than one tagged type in another
> > scope. An inner package is a common choice for another scope.
> >
> static is not the opposite of virtual, see below.  In C++ you can allow
> the normal, implicit dispatch on one type (virtual) and do the other(s)
> explicitly; or have a nonvirtual function that does both/all.  Yes in Ada
> the options are effectively the same.

Another difference in C++ is that a static function does not contain
an implicit "this" variable. This means that static function calls resemble
Ada subprogram calls in the fact that all the parameters must be
passed between the parentheses.

>
> ...
> > What the original author does not mention is that C++ cannot dispatch
> > based upon the return type of a function. This is done cleanly in Ada
and
> > not at all in C++ (or Java).
> >
> Ada uses return type to resolve overloading (at compile time), but
> not to dispatch (possibly at run time).  (C++ and Java do neither.)

Quoting from "Ada as a Second Language" by Cohen:
"If a primitive function of a type T has a result of type T, but no
parameters
of type T or access T, a call on the function can be either nondispatching
or
dispatching depending on the context."

This is clearly more than simple overload resolution.

>
> > In C++ you need to explicitly label a function as "virtual". The default
is
> > "static". In Java the default is the equivalent of virtual, and you must
> > explicitly label "static" functions with the "static" keyword. In Ada
> > functions are primitive to a type if they are declared in the same scope
> > as the declaration of the type. That is, the "primitive" property is
defined
> > by scope, and not by the presence or absence of a reserved word.
> > This is different from C++ and Java, but those languages also differ
> > from each other. Such differences do not prove superiority.
> >
> C++ virtual and Java *final* are opposites, and yes the default is

I stand corrected about the relationship between static and virtual.
Thank you for the correction.

> reversed, but *static* (in both) is quite different -- it specifies
methods
> or variables which are per-class not per-instance.  (As well as having
> other meanings in C++, and C, for things not in a class.)

Static data is similar to data items defined in a package body or
specification in Ada.

Yes, C++ has provided a marvelous set of overloadings for the reserved
word "static", just as Ada has for the reserved word "new".

Jim Rogers





  reply	other threads:[~2003-01-07  1:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-26 21:57 point by point advantages of Ada Russ
2002-12-27 10:54 ` Ingo Marks
2002-12-27 21:11   ` Keith Thompson
2002-12-27 21:31     ` Robert A Duff
2002-12-29 18:31 ` Colin Paul Gloster
2002-12-29 20:09   ` James S. Rogers
2003-01-06 23:13     ` David Thompson
2003-01-07  1:35       ` James S. Rogers [this message]
2003-01-07 19:34         ` Randy Brukardt
2003-01-07 21:53           ` Warren W. Gay VE3WWG
2003-01-08  0:36             ` Richard Riehle
2003-01-08 17:50               ` Warren W. Gay VE3WWG
2003-01-08 20:31             ` Randy Brukardt
2003-01-13 16:37               ` Mark Biggar
2002-12-29 21:56   ` Hyman Rosen
2002-12-29 22:30     ` John R. Strohm
2002-12-29 23:16       ` Hyman Rosen
2003-01-02 14:24         ` Wes Groleau
2003-01-03  8:20           ` Hyman Rosen
2003-01-03 14:00             ` Wes Groleau
2003-01-08 20:55               ` Georg Bauhaus
2002-12-29 19:20 ` chris.danx
replies disabled

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