Anthony Stone writes:
> At 12:49pm on 26 Jan, Bill Long wrote:
>
> > The construct you described is just the computed GOTO statement. That
> > has been "replaced" by the CASE construct.
>
> and Loren P. Meissner wrote:
>
> > A CASE statement springs immediately to mind.
>
> Ah, yes, of course. But is it efficient when there are several hundred CASEs?
> Or does it just step through several hundred comparisons until it finds a
> match?
In principle, the CASE construct is specifically designed to be
efficiently implementable (which is the reason for a few of its
awkward limitations - such as not allowing character type selectors).
Just stepping through the comparisons is not what the construct is
designed for. That would be pretty much indistinguishable from an
IF..ELSEIF..ELSEIF......ELSE..ENDIF block. But there is nothing
that says a compiler couldn't implement it that way.
If you want to *REALLY* know instead of debating abstract points, the
only way to find out is to test with the actual code in question on
the actual compilers in question. But the abstract answer is that
CASE "should" be reasonably efficient. Probably more efficient than
your construct with ASSIGN, because the compiler understands the
structure of the CASE construct, whereas ASSIGN somtimes just makes
compilers essentially give up almost all optimization.
--
Richard Maine
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|