TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show HTML Part by Default
Show All Mail Headers

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

Print Reply
Subject:
From:
Laurent Guerby <[log in to unmask]>
Reply To:
Date:
Thu, 22 Apr 1999 21:47:13 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (26 lines)
Nick Roberts <[log in to unmask]> wrote:
> [...] Personally, I find the ability to define a small selection of my own
> operators in Prolog to be incredibly useful. There's no doubt that, without
> care, you can reduce your code to something resembling the output of a
> spaghetti machine on steroids; so the point is you have to take care not to
> do this. The facility is otherwise tremendously useful, e.g. instead of (in
> Ada):
>
>   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.

--LG

ATOM RSS1 RSS2