comp.lang.ada
 help / color / mirror / Atom feed
* Aspect location in expression function.
@ 2022-05-14 11:47 Blady
  2022-05-14 15:40 ` J-P. Rosen
  0 siblings, 1 reply; 2+ messages in thread
From: Blady @ 2022-05-14 11:47 UTC (permalink / raw)


Hello,

I'm puzzled when I want to changed a function body with aspects to an 
expression function, for instance:

function Length (S : Some_Tagged_Tyoe) return Natural
   with Pre => S.Valid
   is
   begin
   return S.Length;
   end;

have to be changed in:

function Length (S : Some_Tagged_Tyoe) return Natural
   is (S.Length)
   with Pre => S.Valid;

The location of the aspect has moved to the end.

I'd like simply replace the begin block by the expression, as:

function Length (S : Some_Tagged_Tyoe) return Natural
   with Pre => S.Valid
   is (S.Length);

What could be any reasons not to permit it?

Thanks, Pascal.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Aspect location in expression function.
  2022-05-14 11:47 Aspect location in expression function Blady
@ 2022-05-14 15:40 ` J-P. Rosen
  0 siblings, 0 replies; 2+ messages in thread
From: J-P. Rosen @ 2022-05-14 15:40 UTC (permalink / raw)


Le 14/05/2022 à 13:47, Blady a écrit :
> Hello,
> 
> I'm puzzled when I want to changed a function body with aspects to an 
> expression function, for instance:
> 
> function Length (S : Some_Tagged_Tyoe) return Natural
>    with Pre => S.Valid
>    is
>    begin
>    return S.Length;
>    end;
> 
> have to be changed in:
> 
> function Length (S : Some_Tagged_Tyoe) return Natural
>    is (S.Length)
>    with Pre => S.Valid;
> 
> The location of the aspect has moved to the end.
> 
> I'd like simply replace the begin block by the expression, as:
> 
> function Length (S : Some_Tagged_Tyoe) return Natural
>    with Pre => S.Valid
>    is (S.Length);
> 
> What could be any reasons not to permit it?

What you say is logical if you think of an expression function as a 
body; however, it is more like a specification (it can appear in a 
package spec, although it can complete a specification), so the place 
where the aspect appears makes sense. And it would be confusing to allow 
the aspect in two different places. It is the same for separate bodies 
of subprograms.

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52
https://www.adalog.fr

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-14 15:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-14 11:47 Aspect location in expression function Blady
2022-05-14 15:40 ` J-P. Rosen

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