comp.lang.ada
 help / color / mirror / Atom feed
* Renaming in a generic package
@ 1990-11-30 13:26 patrick barnes
  0 siblings, 0 replies; only message in thread
From: patrick barnes @ 1990-11-30 13:26 UTC (permalink / 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1990-11-30 13:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1990-11-30 13:26 Renaming in a generic package patrick barnes

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