Re: Changes to Euphoria
- Posted by ken mortenson <kenneth_john at yah?o.co?> May 30, 2008
- 664 views
Lucius L. Hilley III wrote: > 1) You suggestion looks nice, Yet incomplete. > Explained below: > 2) Replacing or Removing the current while and for > loop structures will make virtually all break > virtually every current euphoria program. > > Incomplete Explained: > You don't show using the index values. > Someone suggested or assumed that it would be Loop. > Thusly: > }}} <eucode> > Loop from 1 by 1 > ? Loop > End Loop > </eucode> {{{ > > The problem is with nested Loops. > }}} <eucode> > for iy = 1 to 5 do > for ix = 1 to 5 do > print(1, {iy, ix}) > enf for > puts(1, 10) > end for > </eucode> {{{ > > Best Regards, > Lucius L. Hilley III - Unkmar Thank you Lucius (and please to me ya!) Your question is specific enough to make it easier to respond to. Something I try but often fail to fully achieve. I appreciate it. I think the FOR loop should be retained for precisely the reasons you've outlined, but I'm going to be more specific in a moment (damn cable modem again, grrrr...) I'd also retain while(1) for the reasons other have given, to not break existing code. Frankly, if my ideas are ever to come to fruition it will likely be the result of a clean sheet approach (which I certainly am not ready to jump into at this point.) I would add Loop...End Loop to Euphoria, because we already have it's complete functionality covered by WHILE and FOR (this is the practical minimalist in me kicking in!) Having said all that, let me respond to your specific issues. I don't like the idea of overloading Loop to be the name of the Index. I prefer to call the Index some other name. Let me see, what would I call it? (give me a break, I don't do stand up for a living!) Suspense over, I prefer the name Index, partly because I'm appalled at single letter var names like i. That's the maintenance programmer in me. Try to find all the references to i in somebodies ten page function and you'd know what I'm talking about. BTW, basic overloads the return value of a function the same way and I much prefer the RETURN idiom. I'd also like to not have RETURN in a routine that reaches it's end, but I digress. For nested loops, my Loop...End Loop would general require assignment to a variable because as you enter another level of nesting it goes out of scope (an var with the same name, Index or whatever, is created for each level of nesting and is visible only at it's level.) Let me repeat the example and hopefully the discussion above makes it a bit clearer... Loop from 1 x=Index -- x will get the values 1,2,3,4,5 Loop from 2 by 2 y=Index -- y will get the values 2,4,6 if (y>5) Exit End Loop if (x>4) Exit End Loop If you did this... Loop from 1 if (Index>4) Exit x=Index -- x will get the values 1,2,3,4 Loop from 2 by 2 if (Index>5) Exit y=Index -- y will get the values 2,4 End Loop End Loop Hopefully the difference is clear. Does that help?