> I was discussing some features of f90/f95 today with some other people here,
> and the syntax of SELECT CASE blocks came up. After consulting Metcalf &
> Reid, we noticed that it is possible to label the SELECT CASE and END SELECT
> statements, as well as the individual CASE statements withing the block.
Yes. Same for DO and IF blocks.
> I
> presume this is simply to clarify the logic of nested SELECT blocks,
One reason. There are two other reasons.
> and has
> no connection to EXIT statements.
Yes. EXIT exits from the next outer block; if you want other behaviour,
you HAVE to use a label. Obviously, the first reason, clarity, is just
for the programmer. The third reason (somewhere between being for the
compiler and for the programmer) is that the names have to match up at
the beginning and end. A common mistake is to end a block somewhere
where it is not intended, but without a name END is just END.
(Especially nasty when you consider that more than one DO block can end
at the same statement.)
Thus, I tend to use labels for all but the shortest blocks (say, for all
which don't fit into one screen in my editor). It makes the code easier
to understand, makes catching mistakes easier during compiles, and the
labels are already there if EXIT needs them.
> Furthermore, it is my understanding that
> C-style fall-through logic with SELECT CASE is not implemented in f90.
If you are referring to the lack of a need for the break stuff, then
yes.
> My friend pointed out that disallowing CASE block fall-through renders
> techniques such as Duff's device impossible, which is not necessarily a Bad
> Thing. ;-)
>
> However, I wonder if it is, in fact, possible to implement Duff's device in
> f90. And perhaps somebody with a better knowledge of [evil coding practices
> in] C could actually explain Duff's device to the rest of us.
Perhaps someone could explain to me what it is at all---I have never
heard of it. (Then again, I tend to avoid C.)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|