Re: while (1) vs. for ( ;; )




In article <4314194B.CD000917@xxxxxxxxxx>, Wolfgang Riedel <wolfgang.riedel@xxxxxxxxxx> writes:
> Richard Heathfield wrote:
> > In the cases where you are sure the parameters are okay, you can call the
> > function directly, avoiding the overhead of the parameter check. (You could
> > reasonably add assertion checks here, since they cannot possibly fire if
> > your program is correct.)
> >
> > When you're not sure, you call the validation function - which either calls
> > the "do it" function directly or, perhaps slightly more cleanly, returns an
> > "everything's fine" value, after which you can proceed to call the "do it"
> > function yourself.
> >
> IIRC that's one reason, why COBOL has multiple entry points into functions.

<OT>
COBOL doesn't have multiple entry points into functions. Functions
in COBOL are a fairly restrictive language feature. I suspect you're
thinking of "programs", which is what COBOL calls the things that are
closest to what C calls "functions", or what are sometimes called
"subroutines".

Standard COBOL does not permit multiple entry points in programs, but
it's an extension in several popular implementations.
</OT>

Multiple entry points would certainly be *a* way of implementing the
design Richard describes, but I don't see much justification for
using them that way. Just using two functions would be clearer and
less error-prone, I suspect. And it strikes me as unlikely that,
conversely, this design would be used to argue for allowing multiple
entry points in a language.

I must admit, though, that I'm not fond of Richard's scheme in most
cases; unless a function is time-critical or the checks are very
expensive I don't see the advantage to skipping the checks. That
shifts the burden of validation from the program to the programmer.

--
Michael Wojcik michael.wojcik@xxxxxxxxxxxxxx

Art is our chief means of breaking bread with the dead ... but the social
and political history of Europe would be exactly the same if Dante and
Shakespeare and Mozart had never lived. -- W. H. Auden
.



Relevant Pages

  • Re: while (1) vs. for ( ;; )
    ... >> Richard Heathfield wrote: ... why COBOL has multiple entry points into functions. ... Fortran and Ada similarly have 'subprogram's linked into a program. ...
    (comp.lang.c)
  • Re: R: GOBACK (was: Perform Thru/Go to vs. Perform - Compile Speed
    ... >between a COBOL program and a Java class is limited at best. ... Multiple entry points are not common in Cobol. ... My tests found the synchronization overhead made the app three times slower. ... SMP was a primative way of multitasking. ...
    (comp.lang.cobol)
  • Re: BASIC is still the best programming language!!!
    ... Except, of course, for COBOL. ... Rubbishing COBOL is allowed, expected, ... Richard Heathfield ... Google users: ...
    (comp.programming)