Re: voting on GOTO
Matt Lewis wrote:
>
> gshingles wrote:
> >
> > Jim Brown wrote:
> > >
> > > It is possible to check if a variable is uninitialized. The recommended
> > > way
> > > to deal with for loops is, if you must jump into a for loop, check if the
> > > variable
> > > is uninitialized and jump to a label that is right before the the
> > > beginning
> > > of the for loop statement to continue iteration.
> > > Jumping into for loops is discouraged, however.
> >
> > That sounds scary. But I vote yes, I'll just probably never use a goto. It
> > may have unforseen benefits and the problems are well known (and therefore
> > avoidable).
>
> It's not really as scary as it sounds. You could get a similar situation
> in this case:
> }}}
<eucode>
> integer x
> if foo then
> x = 1
> end if
> ? x
> </eucode>
{{{
> In other words, you can't use uninitialized variables, and since a loop
> variable is initialized at the for statement...
>
> Matt
yeah, I have run into that.
Forces you to choose.
integer x
if foo then
x = 1
else -- 2 more lines, Choose a direction.
x = 0
end if
? x
--OR
integer x
x = 0 -- 1 line, Initial defaul value, May be overwritten very shortly.
if foo then
x = 1
end if
? x
Lucius L. Hilley III - Unkmar
|
Not Categorized, Please Help
|
|