(j3.2006) Public Comment J32034

Van Snyder Van.Snyder
Tue Jul 15 21:02:42 EDT 2008


On Tue, 2008-07-15 at 18:47 -0600, Jim Giles wrote:
> 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.

Unless we can agree on "always" instead of "likely always" or "maybe
always" or "sometimes" I see no reason not to allow it.

>   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!

See 08-201.

> J. Giles 
> 




More information about the J3 mailing list