From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Ada2012 : Expression functions and extended return statements
Date: Fri, 06 Jan 2012 17:12:29 -0500
Date: 2012-01-06T17:12:29-05:00 [thread overview]
Message-ID: <wcc4nw84h0y.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 02c279d0-7603-4670-af1a-cbf5894231ea@f1g2000yqi.googlegroups.com
Adam Beneschan <adam@irvine.com> writes:
> On Jan 6, 8:33�am, Adam Beneschan <a...@irvine.com> wrote:
>> On Jan 6, 12:45�am, Martin <mar...@thedowies.com> wrote:
>>
>> > Also, on the topic of extended return statements...
>>
>> > What's the rational for having to explicitly repeat the return type?
>> > Seems rather redundant to my eyes. I wouldn't have minded:
>>
>> > function Bar return Some_Type is
>> > begin
>> > � �return Result : <> do
>> > � � � -- something to initialise 'Result'
>> > � �end return;
>> > end Bar;
>>
>> > or even
>>
>> > function Bar return Some_Type is
>> > begin
>> > � �return Result do
>> > � � � -- something to initialise 'Result'
>> > � �end return;
>> > end Bar;
>>
>> > In this case, 'Result' can't be anything other than of type
>> > 'Some_Type' can it?
>>
>> Yes, it can. �If Some_Type is a class-wide type, Result's type must be
>> a specific type. �If Some_Type is, say, an unconstrained array type,
>> Result's type must be a constrained subtype.
>
> Oops, I goofed. Result's type doesn't *have* to be a specific,
> constrained subtype, if there is an initial value (which could be a
> function call, say); the specific type and subtype are then determined
> from the value. If there is no initial value, however, then Result's
> type does have to be constrained.
Well, the examples above don't have an initial value, so I took
your "must be constrained" comment to mean "for this example,
because there's no initial value".
Anyway, the rule is the same as for an object_declaration -- if there's
no initial value, the subtype has to be definite.
- Bob
next prev parent reply other threads:[~2012-01-06 22:13 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-06 8:45 Ada2012 : Expression functions and extended return statements Martin
2012-01-06 9:45 ` stefan-lucks
2012-01-06 10:02 ` Martin
2012-01-06 11:23 ` Peter C. Chapin
2012-01-06 11:37 ` Martin
2012-01-06 13:13 ` Dmitry A. Kazakov
2012-01-06 14:45 ` Martin Dowie
2012-01-06 15:07 ` Martin
2012-01-06 16:40 ` Robert A Duff
2012-01-06 17:04 ` Martin Dowie
2012-01-19 7:47 ` David Thompson
2012-01-06 17:20 ` Dmitry A. Kazakov
2012-01-07 1:47 ` Randy Brukardt
2012-01-07 9:21 ` Dmitry A. Kazakov
2012-01-06 16:45 ` Adam Beneschan
2012-01-06 16:36 ` Adam Beneschan
2012-01-07 14:54 ` stefan-lucks
2012-01-07 15:11 ` Dmitry A. Kazakov
2012-01-08 9:41 ` stefan-lucks
2012-01-09 6:16 ` Randy Brukardt
2012-01-06 15:11 ` J-P. Rosen
2012-01-06 15:26 ` Martin
2012-01-07 1:50 ` Randy Brukardt
2012-01-07 10:12 ` Martin
2012-01-07 12:22 ` Simon Wright
2012-01-07 17:10 ` Martin
2012-01-09 6:21 ` Randy Brukardt
2012-01-09 7:57 ` Martin Dowie
2012-01-31 23:34 ` Yannick Duchêne (Hibou57)
2012-01-06 16:33 ` Adam Beneschan
2012-01-06 16:38 ` Adam Beneschan
2012-01-06 22:12 ` Robert A Duff [this message]
2012-01-31 23:20 ` Yannick Duchêne (Hibou57)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox