comp.lang.ada
 help / color / mirror / Atom feed
From: jimr@col.hp.com (Jim Rogers)
Subject: Re: Please explain why this is wrong...
Date: 10 Feb 1995 05:19:33 GMT
Date: 1995-02-10T05:19:33+00:00	[thread overview]
Message-ID: <3het15$nn7@nonews.col.hp.com> (raw)
In-Reply-To: 3hc3n3$onc@gnat.cs.nyu.edu

Robert Dewar (dewar@cs.nyu.edu) wrote:
: Your program is clearly wrong, and the message from GNAT is quite precise.

Yes, you are correct.  I have learned, thanks to the kind expalnations from
Mssrs Dewar and Nebbe, esxactly how my thinking erred.

: You have a primitive operation New_Square, which is inherited when you
: make a rectangle to give a function New_Square that returns a Rectangle.

This is precisely what I overlooked.  I was attempting to translate a
rather trivial C++ inheritence example into Ada.  I ignored (and was
ignorant of) the inherited constructor.

:............
: If as I suspect, you really did not intend New_Square to be inherited, but
: rather intended it to serve as a constructor only for the Square case, then
: you must be sure that you do not declare in as being primitive. The easiest
: way to declare non-primitive operations is to nest them in a subpackages;

:    package Constructors is
:       function New_Square .. return Square;
:    end Constructors;

This solution was so simple and obvious that I would probably have missed it
for quite a while.  As you have already guessed, I am sure, I am not 
exactly an Ada wizard....yet.

I hope this thread has served as a good example of the problems explained by
Tucker Taft concerning Ada constructors in this same news group.

Thank you all.  I have learned yet again why I prefer Ada to C++.

--
------------------------------------------------------------------------------
| Jim Rogers                    | Dead Reckoning:                            |
| Hewlett-Packard Company       | Traditional form of rough-estimate         |
| Colorado Springs Division     | navigation used for hundreds of years by   |
|                               | sailors, almost all of whom are dead.      |
| jimr@col.hp.com               |                                            |
------------------------------------------------------------------------------



  reply	other threads:[~1995-02-10  5:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-02-07 23:01 Please explain why this is wrong Jim Rogers
1995-02-09  3:55 ` Robert Dewar
1995-02-10  5:19   ` Jim Rogers [this message]
     [not found] ` <3hjj97$dld@gnat.cs.nyu.edu>
     [not found]   ` <3hnquq$j2k@watnews1.watson.ibm.com>
     [not found]     ` <3i3p2q$j7o@gnat.cs.nyu.edu>
1995-02-28  3:54       ` Erik Magnuson
replies disabled

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