Options: Use Forum View Use Proportional Font Show Text Part by Default Show All Mail Headers Message: [<< First] [< Prev] [Next >] [Last >>] Topic: [<< First] [< Prev] [Next >] [Last >>] Author: [<< First] [< Prev] [Next >] [Last >>]

 Subject: Re: Creation of binary operators From: Jens Jakob Jensen <[log in to unmask]> Reply To: [log in to unmask] Date: Fri, 23 Apr 1999 11:48:19 +0200 Content-Type: text/plain Parts/Attachments: text/plain (38 lines)
```Laurent Guerby wrote:

> >   X := Max(Max(Max(Max(23.0-6.5*Y,Y),Y+Z),Y-Z,Limit);
>
>
> 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.

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