Earlier quoted context omitted.
> It's kind of sad that "for" is the keyword programming languages settled on for the loop construct. Many languages only use `for` to mean a for-each style loop where it reads quite naturally: Python - `for n in range(1,10)` Ruby - `for i in 0..10` Rust - `for n in 1..10` (also picked up the bare `loop`) Others support for-each style loops along with the less than ideal C-style for loop: JavaScript - `for (n of [1,2…
Interestingly, the more common way to write that in Ruby would be `(1..10).each { |i| ... }`, or (in the case of needing a multi-line block): ``` (1..10).each do |i| ... end ``` "do" does end up getting used, but only as syntax for a "block" (similar to what other languages would call a lambda). Ruby also has a shorthand for when you want to do something `n` times without caring about the iteration number: ``` 10.tim…
C's 'while' is spelled 'for' in Go
21–30 of 34 posts
Re: C's 'while' is spelled 'for' in Go
#22for-range desperately needs to support some interface that would make user-defined types iterable.
Re: C's 'while' is spelled 'for' in Go
#23It's kind of sad that "for" is the keyword programming languages settled on for the loop construct. Ever since its counterpart "do" was dropped from the for-statement, it's just been utterly nonsensical. I mean how on earth does the word "for" convey a loop? With the recently designed languages like Go and Swift taking so many cues from the Pascal side of the ALGOL language family, how nobody thought to pick up "repe…
Python's "for customer in customers" can't be clearer in my opinion.
is how you'd say that in plain english. Some languages do use foreach as a keyword echoing that.
Re: C's 'while' is spelled 'for' in Go
#24It's kind of sad that "for" is the keyword programming languages settled on for the loop construct. Ever since its counterpart "do" was dropped from the for-statement, it's just been utterly nonsensical. I mean how on earth does the word "for" convey a loop? With the recently designed languages like Go and Swift taking so many cues from the Pascal side of the ALGOL language family, how nobody thought to pick up "repe…
And "do ... while(x)" is a terrible construct because it hides the loop complexity far from the place where a programmer needs to see it.
Re: C's 'while' is spelled 'for' in Go
#25Earlier quoted context omitted.
That was just one way of phrasing it. You could just as easily put it as, "For every piece of cooking equipment, clean it and put it away."
There you need the word "every" to convey that it's a loop. I'd certainly agree that "for each" is much better than "for" alone.
It should not be a shock that the english language doesn't naturally have a single word that can express both a condition/duration as well as a command without any other helper words.
Do is superfluous. Everything in an imperative program is a request to do something.
Re: C's 'while' is spelled 'for' in Go
#26It's kind of sad that "for" is the keyword programming languages settled on for the loop construct. Ever since its counterpart "do" was dropped from the for-statement, it's just been utterly nonsensical. I mean how on earth does the word "for" convey a loop? With the recently designed languages like Go and Swift taking so many cues from the Pascal side of the ALGOL language family, how nobody thought to pick up "repe…
sum = 0
grob (i=0; i
Brilliant.Re: C's 'while' is spelled 'for' in Go
#27It's kind of sad that "for" is the keyword programming languages settled on for the loop construct. Ever since its counterpart "do" was dropped from the for-statement, it's just been utterly nonsensical. I mean how on earth does the word "for" convey a loop? With the recently designed languages like Go and Swift taking so many cues from the Pascal side of the ALGOL language family, how nobody thought to pick up "repe…
Wish they'd called it `grob` and called `return` `bolver` so that we can accept they're just syntactic constructs instead of pointlessly assuming meaning from what are just syntactic constructs. sum = 0 grob (i=0; i Brilliant.
Re: C's 'while' is spelled 'for' in Go
#28Earlier quoted context omitted.
Wish they'd called it `grob` and called `return` `bolver` so that we can accept they're just syntactic constructs instead of pointlessly assuming meaning from what are just syntactic constructs. sum = 0 grob (i=0; i Brilliant.
I feel like this is what learning to program is like when english isn't your first language
Re: C's 'while' is spelled 'for' in Go
#29Earlier quoted context omitted.
There you need the word "every" to convey that it's a loop. I'd certainly agree that "for each" is much better than "for" alone.
" Do your homework" doesn't imply a loop either. Nor does "This could take a while " It should not be a shock that the english language doesn't naturally have a single word that can express both a condition/duration as well as a command without any other helper words. Do is superfluous. Everything in an imperative program is a request to do something.
But "for these subjects, do your home work" does.
> Nor does "This could take a while"
I never claimed that "while" alone is any better.
> It should not be a shock that the english language doesn't naturally have a single word that can express both a condition/duration as well as a command without any other helper words.
I never asked for a magic word. To the contrary, I was lamenting the lost of the helper word "do", making the "for" alone nonsensical.
> Do is superfluous. Everything in an imperative program is a request to do something.
I disagree. I think "for...do" makes things much clearer than "for" alone.
Re: C's 'while' is spelled 'for' in Go
#30It's kind of sad that "for" is the keyword programming languages settled on for the loop construct. Ever since its counterpart "do" was dropped from the for-statement, it's just been utterly nonsensical. I mean how on earth does the word "for" convey a loop? With the recently designed languages like Go and Swift taking so many cues from the Pascal side of the ALGOL language family, how nobody thought to pick up "repe…
While we're being pedantic, "do" is a terrible keyword. I mean, everything in an imperitive program is a request to "do" something. And "do ... while(x)" is a terrible construct because it hides the loop complexity far from the place where a programmer needs to see it.