diff --git a/vcalc/impl/clarifications.rst b/vcalc/impl/clarifications.rst index aedafa9e..333be2e6 100644 --- a/vcalc/impl/clarifications.rst +++ b/vcalc/impl/clarifications.rst @@ -20,67 +20,6 @@ specification without cluttering it. you are left with is a single empty line, which matches "*should* be an empty line at the end of your output". -#. - - .. _clarify:no-decl-cond: - - .. container:: - :name: no-decl-cond - - **no-decl-cond**: - - Declarations in conditionals can lead to undefined values due to - global scoping. Because of the potentially conditional nature of the - execution, it is possible to violate the property of variables - stating that :ref:`variables must be defined before being used ` - (not just declared) by never executing the - definition. For example, the following test would break this property - and is therefore invalid: - - :: - - if (1 < 0) - int i = 0; - fi - int j = i; - -#. - - .. _clarify:no-decl-loop: - - .. container:: - :name: no-decl-loop - - **no-decl-loop**: - - Declarations in loops can lead to undefined or repeatedly defined - values due to global scoping. Because of the potentially conditional - nature of the execution, it is possible to violate the property of - variables stating that :ref:`variables must be defined before being used ` (not just declared) by never executing the - definition. For example, the following test would break this property - and is therefore invalid: - - :: - - loop (1 < 0) - int i = 0; - pool - int j = i; - - As well, because of the potentially repeated nature of the execution, - it is possible to violate the property of variables stating that - :ref:`variables can only be defined once ` by repeating - the declaration. For example, the following test would break this - property and is therefore invalid: - - :: - - int i = 0; - loop (i < 2) - int j = 0; - i = i + 1; - pool; - #. .. _clarify:empty-vector: diff --git a/vcalc/spec/scoping.rst b/vcalc/spec/scoping.rst index 0504147c..7ee543ac 100644 --- a/vcalc/spec/scoping.rst +++ b/vcalc/spec/scoping.rst @@ -1,3 +1,5 @@ +.. _sec:scoping: + Scoping ------- diff --git a/vcalc/spec/statements.rst b/vcalc/spec/statements.rst index 4d679ebd..42070667 100644 --- a/vcalc/spec/statements.rst +++ b/vcalc/spec/statements.rst @@ -24,7 +24,7 @@ Variables have a few properties: - cannot be declared without initialisation. -- cannot be declared more than once in a *VCalc* program. +- cannot be declared more than once in the same :ref:`scope `. Examples of valid declarations are: @@ -131,14 +131,8 @@ A conditional in *VCalc* has the following form: are not a valid condition. Remember, however, that integers undergo an :term:`implicit conversion` to booleans. -- ``statement-*`` is any type of statement *except* a declaration. This - means there can be assignments, nested loops, nested conditionals, - and prints. There does not have to be any statements in the - conditional. - -**Clarification:** Declarations in conditionals can lead to undefined -values due to global scoping. (:ref:`no-decl-cond `) - +- ``statement-*`` is any type of statement. There does not have to be + any statements in the conditional. Loops ~~~~~ @@ -163,15 +157,9 @@ A loop in *VCalc* has the following form: valid condition. Remember, however, that integers undergo an :term:`implicit conversion` to booleans. -- ``statement-*`` is any type of statement *except* a declaration. This - means there can be assignments, nested loops, nested conditionals, - and prints. There does not have to be any statements in the loop, but - without side effects a loop will be infinite (unless it is never - entered). - -**Clarification:** Declarations in loops can lead to undefined or -repeatedly defined values due to global scoping. -(:ref:`no-decl-loop `) +- ``statement-*`` is any type of statement. There does not have to be + any statements in the loop, but without side effects a loop will be + infinite (unless it is never entered). Print ~~~~~