comp.lang.ada
 help / color / mirror / Atom feed
From: barnes@castor.cs.nps.navy.mil (patrick barnes)
Subject: Renaming in a generic package
Date: 30 Nov 90 13:26:40 GMT	[thread overview]
Message-ID: <1713@castor.cs.nps.navy.mil> (raw)

We have the following generic package declaration ( in an Ada class
project ).
-------------------------------------------------------------------------------
generic
  N : POSITIVE;
package MATRIX_STUFF is
  type MATRIX is array(1 .. N, 1 .. N) of INTEGER;
  function MULT(X, Y : MATRIX) return MATRIX;
  function "*" (X, Y : MATRIX) return MATRIX renames MULT;
  -- rename it so the body can be compile as an "is separate" subunit
  procedure PUT(SQUARE : in MATRIX);
end MATRIX_STUFF;

--When we instantiate the generic with a size, 5 for example, then try
to use the "*" operator, we get a run-time constraint error on the
array bounds. 
--We can easily solve the problem by moving the renames clause to the
declarative part where the generic is instantiated.  The question is
why doesn't Ada know the size of the matrix of "*" when MATRIX_STUFF
is instantiated?

Pat

-- 
	Capt Patrick D. Barnes, USAF  	barnes@cs.nps.navy.mil
	NPGSCOL/Code CS/Ba		(408) 646-2830
	Monterey, CA  93943		FAX (408) 646-2814

                 reply	other threads:[~1990-11-30 13:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

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