diff --git a/lang/spec.html b/lang/spec.html index 3d7a4bed..1d47f775 100644 --- a/lang/spec.html +++ b/lang/spec.html @@ -8305,6 +8305,19 @@

Module and program execution

becomes the new root module.

+A configuration is supplied as input to program execution. A +configuration consists of mapping from names of configurable +module-level variables to values. The values in a configuration always belong to +the type anydata&readonly. The value for a variable in the +configuration is used during module initialization to initialize the variable +instead of the value specified in the module. A configurable module-level +variable may require that a configuration include a value for it. Except for +this requirement, a configuration may be empty. Before initializing any module, +the initialization phase must check that there is a value of the correct type +supplied for every configurable module-level variable that requires +configuration. If not, the module initialization phase terminates unsuccessfull. +

+

If the initialization phase of program execution completes successfully, then execution proceeds to the listening phase, which is described in the next section. The termination of the listening phase, which may be successful or @@ -8609,29 +8622,50 @@

Module variable declaration

module-var-decl := module-init-var-decl | module-no-init-var-decl
-module-init-var-decl := metadata isolated-final-quals typed-binding-pattern = expression ;
-isolated-final-quals :=
-  final [isolated-qual]
-  | [isolated-qual [final]]
 

-The scope of variables declared in a module-var-decl is the entire module. Note -that module variables are not allowed to be public. If final is specified, then -it is not allowed to assign to the variable. If the typed-binding-pattern uses -var, then the type of the variable is inferred from the static type -of expression; if the module-var-decl includes final, -the precise type is used, and otherwise the broad type is used. If the -typed-binding-pattern specifies a type-descriptor, then that type-descriptor -provides the contextually expected type for action-or-expr. +A module-var-decl declares a variable. The scope of variables declared in a +module-var-decl is the entire module. Module variables are not allowed to be +public. The variable may be initialized in the declaration or within the +module's init function. If final is specified, then it +is not allowed to assign to the variable after it is initialized. +

+
+module-init-var-decl := metadata module-init-var-quals typed-binding-pattern = module-var-init ;
+module-init-var-quals := (final | isolated-qual | configurable)*
+module-var-init := expression | ?
+
+

+A module-init-var-decl declares and initializes a variable. It is an error for a +keyword to appear more than once in module-init-var-quals. If the +typed-binding-pattern uses var, then the type of the variable is +inferred from the static type of expression; if the module-var-decl +includes final, the precise type is used, and otherwise the broad +type is used. If the typed-binding-pattern specifies a type-descriptor, then +that type-descriptor provides the contextually expected type for action-or-expr.

If a module-init-var-decl includes an isolated-qual, then the variable declared is isolated. In this case, the binding-pattern in the typed-binding-pattern must be just a variable-name, and the expression must be an isolated expression. A variable declared as an isolated variable can be accessed only within a -lock-stmt. The keyword isolated occurring immediately before -the typed-binding-pattern is parsed as part of isolated-final-quals -rather than as part of typed-binding-pattern. +lock-stmt. When an isolated-qual occurs in a position where the grammar would +allow it to be parsed as part of module-init-var-quals or typed-binding-pattern, +the former parse is used. +

+

+If configurable is specified, then the initializer specified in the +module-var-init may be overridden at the time of module initialization by a +value supplied when the program is run. If such a value is supplied, then the +expression in the module-var-init is not evaluated and the variable is +initialized with the supplied value instead. A module-var-init of ? +is allowed only when configurable is specified and means that a +configurable value must be supplied for this variable. If +configurable is specified, then the typed-binding-pattern must use +an explicit type-descriptor rather than var and the binding-pattern +must be just a variable-name. The type specified by the type-descriptor must be +a subtype of anydata.

Summary of changes from 2020R1 to Swan Lake
 fail clause for compound statements. If a check expression
 or action fails, it behaves like a fail statement rather than a
 return statement.
+
  • The language has a concept of configurability: module level variables can be +specified to be configurable, which allows their initial values to +be specified at runtime.