Lambda the Ultimate

inactiveTopic Superb programming style ?
started 8/28/2002; 11:09:08 AM - last post 8/28/2002; 12:02:57 PM
Michael Mounteney - Superb programming style ?  blueArrow
8/28/2002; 11:09:08 AM (reads: 277, responses: 1)
For some reason I keep calling to mind an example from the Springer-Verlag book on Ada style, author Dr (? Henry) Ledgard, which contained in its preamble the assertion that the book demonstrates Dr Ledgard's superb programming style. The example is:

function is_something (some parameters) return Boolean is
begin
if some relationship between parameters then
return TRUE;
else
return FALSE;
end if;
end;

It seems to me that this function violates a couple of rules:

1. It's longer than it needs to be. 2. It has multiple return points.

and that these failings would be rectified by rewriting thus:

function is_something (some parameters) return Boolean is
begin
return some relationship between parameters;
end;

which ought to be obvious to anyone who knows anything about functional or even `expression' languages from Algol-68 onwards.

So why did he do it the way he did ? Are there theoretical reasons for the more verbose version ? I can't believe that it's as straightforward as that he didn't think of the shorter way of doing it.

(Apologies BTW for the lack of indentation---I didn't know how to do the mark-up.)

Ehud Lamm - Re: Superb programming style ?  blueArrow
8/28/2002; 12:02:57 PM (reads: 313, responses: 0)
I am not sure which book you are thinking about. Myself, I prefer the you'd write it, the one liner.

P.S

People that use debuggers sometimes prefer the long version, since it may ease putting in breakpoints.