comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Constraints in extended return
Date: Sat, 19 Mar 2011 09:30:18 -0400
Date: 2011-03-19T09:30:18-04:00	[thread overview]
Message-ID: <wcctyezi6fp.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: m2d3lngzmi.fsf@pushface.org

Simon Wright <simon@pushface.org> writes:

> 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?

You get Constraint_Error if the constraint is wrong.
But this isn't directly related to extended return statements.
You get the same thing for old-fashioned returns:

    function F(...) return String is
    begin
        ...
        return "Hello";
    end F;

    X : String (1..100);

    X := F(...); -- Constraint_Error

> Is there any way for the extended return to determine the constraints of
> the 'target'?

No.  You can do that for 'out' parameters, but unfortunately not for
function results.  So normally, you would avoid constraining at
the call site, and do things like:

   Output : constant Complex_Matrix := Transpose (Input);

- Bob



  reply	other threads:[~2011-03-19 13:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-19 10:42 Constraints in extended return Simon Wright
2011-03-19 13:30 ` Robert A Duff [this message]
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