comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Constraints in extended return
Date: Sat, 19 Mar 2011 10:42:45 +0000
Date: 2011-03-19T10:42:45+00:00	[thread overview]
Message-ID: <m2d3lngzmi.fsf@pushface.org> (raw)

This code transposes a matrix:

   function Transpose (M : Complex_Matrix) return Complex_Matrix
   is
   begin
      return Result : Complex_Matrix (M'Range (2), M'Range (1)) do
        for J in M'Range (1) loop
           for K in M'Range (2) loop
              Result (K, J) := M (J, K);
           end loop;
        end loop;
      end return;
   end Transpose;

This is all very well for providing a value where no constraint is
otherwise imposed, for example as an actual in a subprogram call, but
what about the case where there is a prior constraint?

   Input : Complex_Matrix (1 .. 2, 11 .. 12);
   Output : Complex_Matrix (1 .. 2, 1 .. 2);
begin
   Input := (...);
   Output := Transpose (Input);

Is there any way for the extended return to determine the constraints of
the 'target'? I suspect not, but the language in RM6.5 is deep.



             reply	other threads:[~2011-03-19 10:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-19 10:42 Simon Wright [this message]
2011-03-19 13:30 ` Constraints in extended return Robert A Duff
2011-03-19 13:51   ` Dmitry A. Kazakov
2011-03-19 15:55   ` Simon Wright
2011-03-22  2:02 ` Randy Brukardt
2011-03-22  8:28   ` Simon Wright
replies disabled

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