From: nobody@REPLAY.COM (Anonymous)
Subject: What am I missing here?
Date: 1997/11/18
Date: 1997-11-18T00:00:00+00:00 [thread overview]
Message-ID: <199711182150.WAA17925@basement.replay.com> (raw)
The following code has a compilation error (distilled from a much larger
real-world system):
generic
type Real is digits <>; -- private;
type Index is range <>;
type Vector is array (Index range <>) of Real;
type Matrix is array (Index range <>, Index range <>) of Real;
package Fun_Matrix is
function Row (M : Matrix; I : Index) return Vector;
procedure Set_Row (M : out Matrix; I : in Index; To : in Vector);
--
--------------------------------------------------------------------
-- "&":
-- Concatenates two matrices into upper left and lower right --
corners
-- of the returned matrix.
--
function "&" (M1, M2 : Matrix) return Matrix;
end Fun_Matrix;
package body Fun_Matrix is
function Row (M : Matrix; I : Index) return Vector is
V : Vector (M'range(2));
begin
for J in V'range loop
V(J) := M(I,J);
end loop;
return V;
end Row;
procedure Set_Row (M : out Matrix; I : in Index; To : in Vector) is
begin
for J in To'range loop
M(I,M'first(2) + J - To'first) := To(J);
end loop;
end Set_Row;
--
--------------------------------------------------------------------
-- "&":
-- Concatenates two matrices into upper left and lower right --
corners
-- of the returned matrix.
--
function "&" (M1, M2 : Matrix) return Matrix is
Result : Matrix (Index'first .. Index'first + M1'length(1) +
M2'length(1) - 1,
Index'first .. Index'first + M1'length(2) +
M2'length(2) - 1); -- := (others => (others => 0.0));
Zero1 : constant Vector (M1'range(2)) := (others => 0.0);
Zero2 : constant Vector (M2'range(2)) := (others => 0.0);
begin
for I in M1'range(1) loop
Set_Row (Result, Result'first + I - M1'first(1),
To => Row (M1, I) & Zero2);
--^ Error here *****
end loop;
for I in M2'range(1) loop
Set_Row (Result, Result'first + M1'length(1) + I
- M2'first(1), To => Zero1 & Row (M2, I));
end loop;
return Result;
end "&";
end Fun_Matrix;
with Fun_Matrix;
procedure Fun is
type Real is digits 15;
type Vector is array (Positive range <>) of Real;
type Matrix is array (Positive range <>, Positive range <>) of Real;
package Math is new Fun_Matrix (Real, Positive, Vector, Matrix);
use Math;
begin
null;
end Fun;
The error message is
invalid operand types for operator "&"
This error does not occur if the order of the operands is reversed, nor
if the package is not generic (it is labeled an "instantiation error",
so that's not surprising). Any assistance would be greatly appreciated.
Jeff Carter PGP:1024/440FBE21
My real e-mail address: ( carter @ innocon . com )
"You empty-headed animal-food-trough wiper."
Monty Python & the Holy Grail
Posted with Spam Hater - see
http://www.compulink.co.uk/~net-services/spam/
next reply other threads:[~1997-11-18 0:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-11-18 0:00 Anonymous [this message]
1997-11-18 0:00 ` What am I missing here? Tucker Taft
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox