From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=BAYES_00,FROM_ADDR_WS autolearn=no autolearn_force=no version=3.4.5-pre1 Date: 13 Oct 92 12:07:15 GMT From: cis.ohio-state.edu!news.sei.cmu.edu!firth@ucbvax.Berkeley.EDU (Robert Fi rth) Subject: Re: Can I overload ":="? Message-ID: <1992Oct13.120715.7253@sei.cmu.edu> List-Id: In article <1992Oct12.194719.27071@fcom.cc.utah.edu> val@news.ccutah.edu (Val K artchner) writes: >I would like to define what happens when I assign a value of one type (say >complex) to a variable of another type (say real). Can I change what is >meant in Ada by the operation ":=" like I can do with the other operators, >or am I stuck with assignment of a type to a variable of that type? The direct answer is you can't do it: assignment works only between a value and a variable of the same type, and you can't redefine or overload the ":=" operation. The indirect answer is that you can define a type transfer function as anything you please, eg function Convert (x:Chipmunk) return Integer; and then say line_length := Convert(Dale); And, of course, you can overload Convert on any parameter and result type, so need choose only one name for all type conversion functions. Jean Ichbiah's suggestion (with which I do not agree!) is that you use the unary "+" operator for type conversion.