comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: How to overload assignment in Ada 95?
Date: 1996/12/07
Date: 1996-12-07T00:00:00+00:00	[thread overview]
Message-ID: <dewar.849965916@merv> (raw)
In-Reply-To: 58aclh$ssd@gaia.cc.gatech.edu


Chris asks

"        In 7.6 of the Ada95 LRM, it talks about
user-defined assignment. Could someone please
provide me with an example of how I would in fact
"overload" the assignment operator for a particular
package. The LRM talks about the Ada.Finalization
package and the the "Adjust" procedure. However,
it does not give an example of how I would use
this package to achieve the "overloading" of assignment."


There is user-defined assignment in Ada 95, but you are making the jump
to assume that this means that the assignment "operator" can be overloaded.
It cannot, only operators and subprograms can be overloaded, and assignment
is neither, it is an operation, but not an operator.

Generally it is pretty hopeless to expect to learn how to use features like
this from the RM. In particular, the examples in the RM (which I actually
consider to be annoying redundancy), are not intended to be anything like
a complete learn-by-example set.

Any reasonably comprehensible Ada text, e.g. Barnes or Cohen, will explain
a feature like this in detail with lots of examples, and you will find this
a much more practical way of learning how features like this work. Then the
RM can be used as a reference source once you have a basic understanding.

I asked at Tri-Ada the other day how many people had learned Ada 95 from
the RM. In a room of several hundred people, only four or five put up
their hands (Tucker Taft was one of them :-)

I also asked how many used the RM for reference purposes, and there well
over half put up their hands, which is as one would expect.

It is very important to understand what the RM is and what it is not. It
is NOT a document for learning the language, and it is not a document
that you can expect to be able to read easily without a lot of experience
in language definitions.

The confusion can particularly arise in the case of the Ada RM, since 
unlike some other language definitions (e.g. the Algol-68 report, or the
ANSI PL/1 definition), it has the form of a normal text, and is muuch
more accessible than a typical formal definition. This is valuable in that it makes
it more useful as a reference source to more people, but you must not mistake
this for implying that it is a text book, it is not :-) Furthermore, the
Ada 95 RM has moved further away from text book mode, and further towards
formal definition, so these comments apply even more srtongly to the Ada 95
RM.

As an example of the difference. In a text book, it is often desirable to
state things redundantly. If you state A and state B, and it is the case
that A and B together obviously imply C, then it is still a good idea often
in a text book to state C, especially if A and B are far apart and in
non-obvious places. But in a formal definition, it is redundant to state
C, and thus undesirable, since if you do state C, you run the risk of
stating it in inconsistent form.

The Ada 95 RM (unlike true formal definitions) is not *quite* so hard nosed,
and the notes and examlples (which are all redundant information, and indeed
occasionally run the risk of being wrong, and hence actively unuseeul) are
not part of the standard, but do help some people read it (as I said earlier,
for my own taste I dislike the examples in the RM, and have never read any
of them, but I understand that most people find them helpful, but the risk
is that they expect them to be complete -- they are not!)





  reply	other threads:[~1996-12-07  0:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-12-06  0:00 How to overload assignment in Ada 95? Christopher D Carothers
1996-12-07  0:00 ` Robert Dewar [this message]
1996-12-09  0:00 ` Brad Balfour
1996-12-09  0:00   ` Matthew Heaney
1996-12-10  0:00     ` Robert A Duff
1996-12-10  0:00     ` Brad Balfour
1996-12-10  0:00       ` Larry Kilgallen
1996-12-11  0:00         ` Brad Balfour
1996-12-11  0:00           ` Larry Kilgallen
     [not found]       ` <01bbe6dc$6feb3620$829d6482@joy.ericsson.se>
1996-12-11  0:00         ` Norman H. Cohen
1996-12-11  0:00         ` Brad Balfour
1996-12-10  0:00 ` Jon S Anthony
1996-12-11  0:00   ` Brad Balfour
1996-12-13  0:00     ` Robert A Duff
replies disabled

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