TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Date:
Fri, 23 Apr 1999 11:48:19 +0200
Reply-To:
Subject:
MIME-Version:
1.0
Content-Transfer-Encoding:
7bit
Content-Type:
text/plain; charset=us-ascii
Organization:
Ozwix Data
From:
Jens Jakob Jensen <[log in to unmask]>
Parts/Attachments:
text/plain (38 lines)
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)

ATOM RSS1 RSS2