Why not allow empty code blocks?
Steven D'Aprano
steve at pearwood.info
Sat Jul 30 11:48:55 EDT 2016
On Sat, 30 Jul 2016 11:58 pm, BartC wrote:
> The 'i' is superfluous. Why not:
>
> for 10:
Why bother? What's so special about this that it needs dedicated syntax?
Hypertalk (and related XTalk languages) offer a number of dedicated looping
constructs. Using square brackets [] for optional terms:
repeat [forever]
repeat [for] number [times]
repeat until condition
repeat while condition
repeat with variable = start [to] end
repeat with variable = start [down to] end
That's right, a bare "repeat" on its own gives you an infinite loop. Does
*your* language have special syntax for infinite loops? If not, why not?
We should accept that some things are just a matter of taste and idiom. When
I wrote code in Hypertalk, I used those six different forms and found them
perfectly reasonable *in that language*. When I write Python code, I never
find myself wishing I could write Hypertalk code repeat loops (not since
1998 or thereabouts) in Python, since they don't "feel" right for the
language: at best, it would be like suddenly dropping into Lolcat in the
middle of an ordinary English sentence. Good for a giggle, but that's all.
--
Steven
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list
mailing list