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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,86bb11cd9af49a58 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Vinzent 'Gadget' Hoefler Newsgroups: comp.lang.ada Subject: Re: overloading operators with private variables Date: Wed, 29 Dec 2004 17:22:33 +0000 Message-ID: <16484311.lexTNh36f7@jellix.jlfencey.com> References: <1104336536.856474.279370@f14g2000cwb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: individual.net iNSeTnzpcYzPQlLGglU3cgm2jVe/FLjvAuHg5eBkSVN+CX+77n X-Phone: +41 62 961 13 52 Xref: g2news1.google.com comp.lang.ada:7302 Date: 2004-12-29T17:22:33+00:00 List-Id: R wrote: > I was trying to overload my test record. For example the > multiplication. > > procedure Main is > object : testclass.rec1; > object2 : testclass.rec1; > objectMul : testclass.rec1; > begin > testclass.Create(object, 100); > testclass.Create(object2, 10); > objectMul := object * object2; > Put_Line(Integer'Image(testclass.Get(objectMul))); > end Main; Yes, classical beginner's problem. ;-) I suppose you have the according "with"-clauses in there, right? Remember that "with" doesn't make anything visible, and that's the problem: function testclass."*" is not visible, function Standard."*" is (it always is), but expects different types of parameters, of course. So there are three possible solutions: 1) objectMul := testclass."*"(object, object2) It's clean, it says where it's coming from, it works. So it's perfect, isn't it? --- No? You're right. In most cases you don't want that, because if you would have wanted a function call that really looks like a function call, you would have declared it that way. ;-) So there's solution 2) Insert a "use type testclass.rec1" clause at the beginning to make these _operations_ on the type directly visible. This is what I would suggest and this is what one usually wants. Well, there's still solution 3) Insert a "use testclass" clause at the beginning to make everything from testclass directly visible. Most people consider this a bad idea, and they're right, for different reasons. So I wouldn't recommend it neither. So for now it's best to forget about solution 3. Vinzent.