armstron@sjuvax.UUCP (L. Armstrong) (05/23/85)
*** REPLACE THIS LINE WITH YOUR MESSAGE *** Does anyone have any information on strategies that might be used to resolve an assignment statement in Ada? I'm not sure if the term "resolve" is universally used, so let me explain just what I mean. If we had the following code : procedure P is x : int; y : int; x : float; begin x := y; end P; Then the resolver would determine that we wish to use the integer x, and not t the float x. However in the program : procedure P is procedure Q; x : <type 1> y : <type 2> z : <type 1> procedure Q is x : <type 1> y : <type 1> z : <type 3> begin x := y + z; end Q; begin <statements in P> end P; You can see, our problem is expanded, and the resolver would have to determine that we want to use the x and y of type 1 from Q, and the z of type 1 from P. And the problems can go on and on. Also, there may be cases which simply cannot be resolved, as in the case of : procedure P is x, y, z : float; x, y, z : integer; begin x := y + z; end P; I am currently tring to implement a good method of resolving these expressions, and if anyone can offer suggestion how such a situation might be handled, it would be greatly appreciated. Thanx, -- Len P.S. The Ada code may not be syntactically perfect -- sorry if it's not. -- Len Armstrong St. Joseph's University {astrovax | bpa | burdvax | allegra }!sjuvax!armstron
gvcormack@watdaisy.UUCP (Gordon V. Cormack) (05/24/85)
> Does anyone have any information on strategies that might be used to > resolve an assignment statement in Ada? > > I'm not sure if the term "resolve" is universally used, so let me explain > procedure P is > x : int; > y : int; > x : float; > begin > x := y; > end P; This requires a reasonably straightforward extension to any Ada overloading algorithm to allow variables as well as functions etc. to be overloaded. One has to treat := as an overloaded operator that is applicable to all non-limited types. An good entry into the literature on overload resolution is the introduction to T.P. Baker, "A one-pass algorithm for overload resolution in Ada", ACM TOPLAS 4:4 , 601-614. I should note that the above program is not legal in Ada; variables may not be overloaded. -- Gordon V. Cormack CS Department, University of Waterloo gvcormack@watdaisy.uucp gvcormack%watdaisy@waterloo.csnet