четверг, 3 мая 2018 г., 11:25:34 UTC+3 пользователь rog написал:
>
> FWIW, the thing I miss sometimes is the equivalent of C's: 
>
>      while((x = next()) != nil) { 
>          something() 
>      } 
>
> In Go you need to do either: 
>
>      for x = next(); x != nil; x = next() { 
>          something() 
>      } 
>
> which duplicates the per-iteration expression, or: 
>
>      for { 
>           x = next() 
>           if x == nil { 
>               break 
>           } 
>           something() 
>      } 
>
> which is 4 lines longer and the invariant is inverted. 
>
> A two-part for statement could potentially do that: 
>
>     for x = next; x != nil { 
>         something() 
>     } 
>
> but it's too subtly different from the normal form to be a good language 
> change. 
>

Two-part for statement - that is exactly what I suggested couple years ago, 
and core-team
already rejected that.

-- 
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