Laurent Guerby wrote:
> Nick Roberts <[log in to unmask]> wrote:
> > X := Max(Max(Max(Max(23.0-6.5*Y,Y),Y+Z),Y-Z,Limit);
>
> What about:
>
> X := Max (Float_Values => (23.0-6.5*Y, Y, Y+Z, Y-Z, Limit));
>
> With:
>
> type Float_Array is array (Natural range <>) of Float;
> function Max (Float_Values : in Float_Array) return Float;
>
> There are of course also other function-based ways to improve
> readability here without need for language built-in fancy operator
> creation.
What about:
declare
function Max (v1, v2, v3, v4, v5 : Float) return Float is
begin
return Max (Max (Max (Max (v1, v2), v3), v4), v5);
end Max;
pragma Inline (Max);
begin
X := Max (23.0 - 6.5 * Y,
-- Y, -- No need: This is always <= either Y+Z or Y-Z
Y + Z,
Y - Z,
Limit);
end;
I think that's pretty readable ;-)
(sorry; couldn't resist)
|