The lack of citations makes the content untrustworthy to me, but this 
English Wikipedia article on loops claims some history starting with the do 
loop in FORTRAN (1957): https://en.wikipedia.org/wiki/For_loop

This article says the three part for loop was introduced in C/C++ (1972), 
and container iteration was introduced in Maple (1980).

for e in c while w do
    # loop body
od;

The people writing these articles claim “Do while”, “While”, “For”, 
“Foreach”, and “Infinite” are loop constructs. All of these are done by for 
in Go.

Another observation from this novice Go programmer: I'm puzzled why there's 
> no while statement.


I think “it was an arbitrary choice based on experience” might be the 
answer but I don’t know. I like having the one keyword.

Matt

On Tuesday, May 1, 2018 at 6:11:04 AM UTC-5, Hugh Fisher wrote:
>
>
> Another observation from this novice Go programmer: I'm puzzled why
> there's no while statement.
>
> I know it's possible to use a for, but it doesn't feel right to me. I 
> always
> think of for loops as for iterating over data structures. Originally just
> arrays, but languages like Python and Objective-C have extended for
> loops to other collections as well. "Looping until some condition is met"
> for me is a different control structure and needs a different keyword.
>
> There'd be overlap with the for statement, but if-then-else and switch
> with boolean case overlap too.
>
> And since while has been a reserved keyword in a lot of programming
> languages for many decades, I would bet a reasonable amount of
> money that a while statement could be added to Go right now and not
> break anyone's production code.
>
> cheers,
> Hugh Fisher
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to