From: Russ Cox if
, for
, and switch
statement is considered to be in its own implicit block.switch
statement,
- and each communication clause in a select
statement
+ switch
or select
statement
acts as an implicit block.
-QualifiedIdent = [ ( LocalPackageName | PackageName ) "." ] identifier . -LocalPackageName = identifier . +QualifiedIdent = [ PackageName "." ] identifier . PackageName = identifier .@@ -1765,21 +1763,11 @@ A qualified identifier accesses an identifier in a separate package. The identifier must be exported by that package, which means that it must begin with a Unicode upper case letter (§Exported identifiers). -
-The LocalPackageName is that of the package in which the qualified identifier -appears and is only necessary to access names hidden by intervening declarations -of a package-level identifier. -
Math.Sin -mypackage.hiddenName -mypackage.Math.Sin // if Math is declared in an intervening scope-TODO: 6g does not implement LocalPackageName. Is this new? -Is it needed? -
@@ -3183,10 +3171,8 @@ if x > 0 {
-An "if" statement may include a simple statement before the expression. -The scope of any variables declared by that statement -extends to the end of the "if" statement -and the variables are initialized once before the statement is entered. +The expression may be preceded by a simple statement, which +executes before the expression is evaluated.
@@ -3255,11 +3241,8 @@ Otherwise control flows to the end of the "switch" statement.-A "switch" statement may include a simple statement before the -expression. -The scope of any variables declared by that statement -extends to the end of the "switch" statement -and the variables are initialized once before the statement is entered. +The expression may be preceded by a simple statement, which +executes before the expression is evaluated.
@@ -3355,6 +3338,11 @@ there can be only one type per "case", and the "fallthrough" statement is not allowed. ++The type switch guard may be preceded by a simple statement, which +executes before the guard is evaluated. +
+For statements
@@ -3384,10 +3372,8 @@ for a < b { A "for" statement with a "for" clause is also controlled by its condition, but additionally it may specify an init and a post statement, such as an assignment, -an increment or decrement statement. The init statement (but not the post -statement) may also be a short variable declaration; the scope of the variables -it declares ends at the end of the statement -(§Declarations and scope rules). +an increment or decrement statement. The init statement may be a +short variable declaration, but the post statement must not.
@@ -3562,8 +3548,6 @@ which single communication will execute.The receive case may declare a new variable using a short variable declaration (§Short variable declarations). -The scope of such variables continues to the end of the -respective case's statements.
@@ -4057,11 +4041,10 @@ identifer will have the formp1.
N. If no name is provided in the import declaration, P will be the package name declared within the source files of the imported package. Finally, if the import declaration uses an explicit period -(.
) for the package name, N will appear -in the package-level scope of the current file and the qualified name is -unnecessary and erroneous. In this form, it is an error if the import introduces -a name conflict. +(.
) for the package name, N will be declared +in the current file's file block and can be accessed without a qualifier. +In this table, assume we have compiled a package named
math
, which exports functionSin
, and @@ -4079,6 +4062,10 @@ import . "lib/math" SinMulti-file packages
++TODO: Update for whole-package compilation. +
+If a package is constructed from multiple source files, all names at package-level scope, not just exported names, are visible to all the