• Robert Griesemer's avatar
    go spec: clarify semantics of range clause · 54731036
    Robert Griesemer authored
    This CL proposes some subtle language changes
    in an attempt to clarify the semantics of range
    clauses and simplify uses of maps.
    
    - nil maps behave like empty maps; but attempting
      to set a value in a nil map causes a run-time panic
    - nil channels are never ready for communication;
      sending or reading from a nil channel blocks forever
    - if there is only one index iteration variable in a
      range clause and len(range expression) would be a constant,
      the range expression is not evaluated.
      (was discrepancy with len/cap before)
    - the notion of what is a constant expression len(x)
      for (pointer to) arrays x has been generalized and
      simplified (can still be syntactically decided)
      (before: more restrictive syntactic rule that was not
      consistently implemented)
    
    Fixes #1713.
    
    R=r, rsc, iant, ken2, r2, bradfitz, rog
    CC=golang-dev
    https://golang.org/cl/4444050
    54731036
go_spec.html 153 KB