The only "disadvantage" i could think would be increasing the ways one could create variables:
var i int i := 0 :i = 0 and it allows this madness: :a, b, :c, d, :e = 0, 1, 2, 3, 4 Otherwise i like the idea, but i don't mind using the long version in pro of simplicity. On Mon, 28 Dec 2020, 16:40 bobj...@gmail.com, <bobja...@gmail.com> wrote: > For the case of multiple variable assignment where some of the target > variables are to be created in the local scope and some are to be found in > the existing scope... > > Allow: > > existingVar, :newVar = 1, 2 > > instead of: > > var newVar int > existingVar, newVar = 1, 2 > > That additional line for explicit local var declaration clutters the > program and could even be a bit confusing. > > With this suggestion, current syntax and semantics of multiple assignment > stay the same. Use of the more concise syntax is optional, of course. > > Advantages: > - More readable > - More concise > - Easier to understand at a glance -- current rules are a tad complex and > require knowledge of previously-declared variables in the current block > - Does not break existing programs > - I look at this as "factoring out" the colon :) > > Disadvantages: > - Can't think of any > > For me, the most common use case is where the first variable exists > outside of the enclosing block and the second is an error to be handled > locally: > > var err error > loopCount, err = strconv.Atoi(arg) > if err != nil { > ... > > Always bothers me to have to insert that "err" declaration. To me, this > seems much nicer: > > loopCount, :err = strconv.Atoi(arg) > if err != nil { > ... > > I think the above is a worthwhile improvement and should be considered. > > Thoughts? > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/ddd97db1-7a02-406b-b905-3f94f533d8c2n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/ddd97db1-7a02-406b-b905-3f94f533d8c2n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAE%3DAWBWvscourH3-pu73PJEmVK00Gk-ex6f9Sz%3D_J12MVA9KOg%40mail.gmail.com.