-- Code of Figure 9.9, pages 377-378 from -- Kenneth C. Louden, Programming Languages -- Principles and Practice 2nd Edition -- Copyright (C) Brooks-Cole/ITP, 2003 package body ComplexNumbers is type ComplexRecord is record re, im: Float; end record; function "+"(x,y: in Complex) return Complex is t: Complex; begin t := new ComplexRecord; t.re := x.re + y.re; t.im := x.im + y.im; return t; end "+"; -- more operations here function makeComplex (x,y: in Float) return Complex is begin return new ComplexRecord'(re => x , im => y); end makeComplex; function realPart (z: in Complex) return Float is begin return z.re; end realPart; function imaginaryPart (z: in Complex) return Float is begin return z.im; end imaginaryPart; end ComplexNumbers;