2-part for

74 views
Skip to first unread message

Costin Chirvasuta

unread,
Apr 26, 2012, 10:29:56 AM4/26/12
to golang-nuts
Hello,

Sorry if this was already discussed, but I can't find it anywhere.

Wouldn't it be nice to have a 2-part for form such as:

for ch, err = b.ReadRune; err != nil {
// ...
}

I've encountered the need for something like this quite a few times.

Jiří Zárevúcky

unread,
Apr 26, 2012, 11:36:16 AM4/26/12
to golan...@googlegroups.com
On Thursday, 26 April 2012 16:29:56 UTC+2, Costin Chirvasuta wrote:
Wouldn't it be nice to have a 2-part for form such as:

for ch, err = b.ReadRune; err != nil {
    // ...
}

I've encountered the need for something like this quite a few times.

I'm afraid this would be too confusing. Think the following two statements: 

for ch, err = b.ReadRune; err != nil { 
    // ... 


for ch, err = b.ReadRune; err != nil; { 
    // ... 
}

A single character difference, drastic change in semantics. Nope, that's not a good idea.

Jiří Zárevúcky

unread,
Apr 26, 2012, 11:40:29 AM4/26/12
to golan...@googlegroups.com

On Thursday, 26 April 2012 17:36:16 UTC+2, Jiří Zárevúcky wrote:
On Thursday, 26 April 2012 16:29:56 UTC+2, Costin Chirvasuta wrote:
Wouldn't it be nice to have a 2-part for form such as:

for ch, err = b.ReadRune; err != nil {
    // ...
}

I've encountered the need for something like this quite a few times.

I'm afraid this would be too confusing. Think the following two statements: 


On another though, I too have encountered cases where something like this would be quite comfortable.
Perhaps it's a valid reason why Go could have a separate while statement.

Reply all
Reply to author
Forward
0 new messages