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.

Reply via email to