constant a = 0
+module M {
+ constant a = 1
+ constant b = a # a refers to M.a here; b = 1
+ constant c = .a # a refers to a here; c = 0
+}
+diff --git a/docs/fpp-spec.html b/docs/fpp-spec.html index ba8ae4900..11261ce23 100644 --- a/docs/fpp-spec.html +++ b/docs/fpp-spec.html @@ -14526,7 +14526,7 @@
M.a. (This is also the way that
-name qualification works in Python, Java, and Scala.)
+name qualification works in Python, Java, and Scala.
+The C++ equivalent is M::a.)
Inside the module, you can use the qualified name or the unqualified
name.
Outside the module, you must use the qualified name.
@@ -2119,6 +2120,31 @@ Optionally, you can write a qualified name with a leading dot. +This form says to compute the name starting at the top, instead +of starting at the current level. +For example:
+constant a = 0
+module M {
+ constant a = 1
+ constant b = a # a refers to M.a here; b = 1
+ constant c = .a # a refers to a here; c = 0
+}
+As shown in the example, the leading-dot form is useful when
+a definition is hidden or shadowed by another definition
+with the same unqualified name in an inner scope.
+In the example above, inside module M, the name a
+refers to M.a, so to refer to the constant a defined at the top
+level, we have to write .a.
+(The C++ equivalent is ::a.)
As with namespaces in C++, you can close a module definition and reopen it later. All the definitions enclosed by the same name go in the module @@ -14632,6 +14658,20 @@
You can also write a location specifier using the leading +dot syntax, like this:
+module M { locate constant .a at "M.fpp" }
+In this case, the name .a is resolve to a, not M.a.
+The leading dot says to start the resolution at the top level,
+regardless of where the location specifier appears in the model.
locate constant a at "Constants/a.fpp"
+locate constant .a at "Constants/a.fpp"
Notice that the tool uses the leading dot +form of the definition name. +That is because the names are always specified from the top level. +The leading dot ensures that the name will have the same meaning +regardless of where the location specifier appears in the model.
+locate constant a at "a.fpp"
+locate constant .a at "a.fpp"