From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3d9f3074dc2c4699 X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: How to overload assignment in Ada 95? Date: 1996/12/07 Message-ID: #1/1 X-Deja-AN: 202860511 distribution: usa references: <58aclh$ssd@gaia.cc.gatech.edu> organization: New York University newsgroups: comp.lang.ada Date: 1996-12-07T00:00:00+00:00 List-Id: 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!)