comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Constraints in extended return
Date: Sat, 19 Mar 2011 15:55:00 +0000
Date: 2011-03-19T15:55:00+00:00	[thread overview]
Message-ID: <m28vwbgl63.fsf@pushface.org> (raw)
In-Reply-To: wcctyezi6fp.fsf@shell01.TheWorld.com

Robert A Duff <bobduff@shell01.TheWorld.com> writes:

> 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);

Thanks, that's what I thought would be the case. This will constrain my
solution :-) but we all need boundaries!

> - Bob



  parent reply	other threads:[~2011-03-19 15:55 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
2011-03-19 13:51   ` Dmitry A. Kazakov
2011-03-19 15:55   ` Simon Wright [this message]
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