(j3.2006) Public Comment J32034
Jim Giles
JamesGiles-2
Tue Jul 15 20:47:17 EDT 2008
Van Snyder wrote:
> On Tue, 2008-07-15 at 17:53 -0600, Jim Giles wrote:
>> And, I also don't think it's a good idea that all constructs be
>> allowed a specification part.
>
> Is there a reason other than personal preference for this sentiment?
>
> If every <block> is allowed to have a specification part, you would
> still be allowed to write
>
> IF ( <condition> ) THEN
> BLOCK
> <specification-part>
> <execution-part>
> END BLOCK
> END IF
Well, the idiom is more likely to be (for reasons below):
BLOCK
<specification-part>
IF (<condition>) THEN
<execution-part>
END IF
END BLOCK
> instead of
>
> IF ( <condition> ) THEN
> <specification-part>
> <execution-part>
> END IF
This is unlikely (or undesirable, if inexperienced programmers start to
do it). This is because later maintenence is likely to add ELSE IF and/or
ELSE parts to the IF construct, and they will very frequently need to deal
with
the same local variables. Savvy programmers are likely to always prefer
to declare the variables outside the construct. The same applies to SELECT-
CASE constructs - they're more likely to need the BLOCK immediately
outside. For DO, the most common example used with respect to the idea
of local scoping is the desire to make the index variable local - but that
can't be declared inside the loop!
J. Giles
More information about the J3
mailing list