Sorry for late reply: yes, it’s sugar, and a first implementation might be to have the compiler simply rewrite it like a macro, as in your example.
And I realize that my example was more verbose than need be. We don’t call an iterator on arrays, maps, etc, so my example should have been: for t := range tokenizer { // etc } I.e., need to call .Range(), since the point of the ‘interface' is to let the compiler infer how to iterate. It’s quite a lot less boilerplate, while keeping the intent clear, and maybe even preventing some classes of user error. On Friday, July 20, 2018 at 9:24:18 AM UTC-4, Juliusz Chroboczek wrote: > > > for t := range tokenizer.Next() { > > // etc > > } > > Isn't that just syntactic sugar for > > for t, more := f(); more; t, more = f() { > ... > } > > ? > > > -- 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.