diff --git a/docs/source/programming.rst b/docs/source/programming.rst index 824162299..f13a78c58 100644 --- a/docs/source/programming.rst +++ b/docs/source/programming.rst @@ -111,11 +111,14 @@ Be careful when importing other modules; blocks in your own code cannot have the same name as a block defined in an imported module or library. .. sidebar:: - Use qualified names ("dotted names") to reference symbols defined elsewhere + Using qualified names ("dotted names") to reference symbols defined elsewhere - In prog8 every symbol is 'public' and can be accessed from anywhere else, given its *full* "dotted name". + Every symbol is 'public' and can be accessed from anywhere else, when given its *full* "dotted name". So, accessing a variable ``counter`` defined in subroutine ``worker`` in block ``main``, can be done from anywhere by using ``main.worker.counter``. + Unlike most other programming langues, as soon as a name is scoped, + Prog8 treats it as a name starting in the *global* namespace. + Relative name lookup is only performed for *non-scoped* names. The address can be used to place a block at a specific location in memory. Usually it is omitted, and the compiler will automatically choose the location (usually immediately after diff --git a/docs/source/syntaxreference.rst b/docs/source/syntaxreference.rst index f11acddf0..c5af07c1d 100644 --- a/docs/source/syntaxreference.rst +++ b/docs/source/syntaxreference.rst @@ -270,6 +270,15 @@ Examples of valid identifiers:: приблизительно π +**Scoped names** + +Sometimes called "qualified names" or "dotted names", a scoped name is a sequence of identifiers separated by a dot. +They are used to reference symbols in other scopes. Note that unlike many other programming languages, +scoped names always need to be fully scoped (because they always start in the global scope). Also see :ref:`blocks`:: + + main.start ; the entrypoint subroutine + main.start.variable ; a variable in the entrypoint subroutine + Code blocks ----------- diff --git a/docs/source/todo.rst b/docs/source/todo.rst index d013d03eb..9ac78da93 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,6 +2,7 @@ TODO ==== +- add functions to const eval that we know how to evaluate (math.*, etc) - [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 .... ...