comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@world.std.com>
Subject: Re: Inheritance and Polymorphism in Ada !!
Date: 1999/10/18
Date: 1999-10-18T00:00:00+00:00	[thread overview]
Message-ID: <wccvh841u7i.fsf@world.std.com> (raw)
In-Reply-To: 3806DC34.1513E8B1@frqnet.de

Andreas Winckler <andreas.winckler@frqnet.de> writes:

> Yes, but in my opinion polymorphism is kind of restricted in Ada.

Compared to which language?  Polmorphism in Ada works pretty much the
same as in Java, C++, Eiffel, &c, roughly speaking -- although the
syntax is rather different.  I suppose you could argue that Ada's
polymorphism is more restrictive (for good reason!) than Smalltalk's,
but your example wouldn't be allowed in Smalltalk anyway, so I don't
know what you're comparing Ada against.

> See this example:
> 
> 1  procedure inheritance_polymorphism is
> 2
> 3  type type_a is tagged record
> 4           first_field	: integer;
> 5       end record;
> 6
> 7  type type_b is new type_a with record
> 8           second_field : integer;
> 9       end record;
> 10
> 11 type pointer_type is access all type_a'class;
> 12 pointer	: pointer_type;
> 13
> 14 begin
> 15     pointer := new type_b;
> 16     type_b(pointer.all).second_field := 1;
> 17 end inheritance_polymorphism;
> 
> See line 16, the type of the referenced object must be known in advance.
> With "pointer.second_field :=1" the compiler fails. It seems that the
> strong typing restricts the features of polyormism in Ada. Any comments?
> Am I wrong?

Hard to tell -- you just said it's "restrictive", but you didn't say
compared to *what*.  It seems clear to me that you shouldn't *want* the
above example to be legal.

- Bob
-- 
Change robert to bob to get my real email address.  Sorry.




  parent reply	other threads:[~1999-10-18  0:00 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-10-15  0:00 Inheritance and Polymorphism in Ada !! Chango Cho
1999-10-15  0:00 ` Andreas Winckler
1999-10-15  0:00   ` Richard D Riehle
1999-10-15  0:00     ` Matthew Heaney
1999-10-15  0:00       ` Richard D Riehle
1999-10-18  0:00       ` Robert Dewar
1999-10-23  0:00         ` Richard D Riehle
1999-10-24  0:00           ` Robert Dewar
1999-10-24  0:00             ` Brian Rogoff
1999-10-26  0:00               ` Robert Dewar
1999-10-25  0:00             ` Robert A Duff
1999-10-26  0:00               ` Robert Dewar
1999-10-26  0:00                 ` Robert A Duff
1999-10-18  0:00       ` Robert A Duff
1999-10-19  0:00         ` Robert Dewar
1999-10-20  0:00           ` Robert A Duff
1999-10-21  0:00             ` Robert Dewar
1999-10-21  0:00             ` Paul Duquennoy
1999-10-21  0:00             ` Simon Wright
1999-10-21  0:00               ` Robert A Duff
1999-10-22  0:00         ` Matthew Heaney
1999-10-15  0:00   ` Stephane Barbey
1999-10-15  0:00   ` tmoran
1999-10-15  0:00     ` tmoran
1999-10-15  0:00   ` Matthew Heaney
1999-10-18  0:00     ` Robert A Duff
1999-10-18  0:00       ` Brian Rogoff
1999-10-15  0:00   ` Lutz Donnerhacke
1999-10-18  0:00   ` Robert A Duff [this message]
1999-10-15  0:00 ` Ted Dennison
1999-10-15  0:00 ` Lutz Donnerhacke
replies disabled

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