comp.lang.ada
 help / color / mirror / Atom feed
From: cis.ohio-state.edu!news.sei.cmu.edu!firth@ucbvax.Berkeley.EDU  (Robert Fi
Subject: Re: Can I overload ":="?
Date: 13 Oct 92 12:07:15 GMT	[thread overview]
Message-ID: <1992Oct13.120715.7253@sei.cmu.edu> (raw)

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.

             reply	other threads:[~1992-10-13 12:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-10-13 12:07 cis.ohio-state.edu!news.sei.cmu.edu!firth [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-10-14 20:27 Can I overload ":="? Mark A Biggar
1992-10-14 16:22 dog.ee.lbl.gov!hellgate.utah.edu!caen!destroyer!cs.ubc.ca!utcsri!torn!csd.unb.ca!morgan.ucs.mun.ca!nstn.ns.ca!mmaccorm
1992-10-13  4:08 Can I overload ": ="? Michael Feldman
replies disabled

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