From: Dossy Date: 2002-07-10T01:10:54+09:00 Subject: Re: for ... else ... end On 2002.07.09, Sean Russell wrote: > Yukihiro Matsumoto wrote: > > > But I don't feel "for .. else" is intuitive. The "else" seem like > > indentation mistake rather than loop termination hook. Maybe there > > can be a more suitable keyword. > > Here are the suggestions, so far: > > else > ensure > finally I'd add "afterwards" as the most logical English keyword: for ... # do stuff afterwards # do stuff end But then it's not clear if afterwards gets done always, or only if the loop iterates completely. I don't think "ensure" should be used, because that seems like it should always be executed upon exiting the iterator regardless of if it completely iterated or was broken out of. I think the "else" syntax for indicating code that should be executed when the iterator is empty is cool, but unnecessary as there are other ways of implementing the same behavior just as clearly. I definitely think the choice of "else" in Python was a poor choice as you're really not doing "this or else that" with regard to the iterator. I think "then" might be the more appropriate keyword: for ... # do stuff then # do stuff when finished iterating end Breaking out of the iterator breaks out of the whole construct, skipping the "then" clause code. -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)