TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Classic View

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

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

Print Reply
Laurent Guerby <[log in to unmask]>
Thu, 22 Apr 1999 21:47:13 +0200
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