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,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9fb64e4c58f1fe X-Google-Attributes: gid103376,public From: johnherro@aol.com (John Herro) Subject: Re: overload ":=" ??? Date: 1996/07/18 Message-ID: <4smd11$5bl@newsbf02.news.aol.com>#1/1 X-Deja-AN: 168762464 sender: root@newsbf02.news.aol.com references: <31ED3F5F.1135B4EA@jinx.sckans.edu> organization: America Online, Inc. (1-800-827-6364) newsgroups: comp.lang.ada Date: 1996-07-18T00:00:00+00:00 List-Id: David Morton writes: >Is there a way to overload the assignment operator ":=" ? Unfortunately, no. However, you can write your own procedure Assign or Set. The difficulty with that is that you may forget to call it, and use the predefined := instead. The workaround is to make the type of the object you're assigning limited private. Then the compiler will force you to call your Set procedure, and won't allow you accidentally to use := (outside the package). For example: package P is type Stack is limited private; ... procedure Set (Left: out Stack; To: in Stack); end P; with P; use P; procedure Main is A, B : Stack; ... begin ... Set(A, To => B); -- Legal A := B; -- Illegal. Compiler will catch this. end Main; There's more information about when to use private types and when to use limited private types in my Ada Tutor program. I hope this helps. - John Herro Software Innovations Technology http://members.aol.com/AdaTutor ftp://members.aol.com/AdaTutor