Intermediate scopes in Oberon-07
Being able to declare types locally is not so much about information hiding as it is making the code easier to understand.
There are 2 separate questions: Should a language allow to.. (1) *declare* local types and constants, in addition to local variables (2) *access* locally declared types and constants within nested scopes Few people would object to allowing (1) although one might argue even about that. As Chris has pointed out, this feature doesn’t seemed to be used much in practice. In the entire PO2013 system with 850 procedures (of which only 17 are local ones), there is only ONE local TYPE declaration and only 8 local CONST declarations. With respect to (2), Chris’ main point was that - now that local variables can no longer be accessed in nested scopes anyway (since the Oberon-07 revision) - what is an example of a genuine use for an intermediate TYPE if intermediate *variables* of that type are inaccessible in nested scopes. ——————
On 2018-02-11 11:20, Andreas Pirklbauer wrote:
In the entire PO2013 system with850 procedures (of which only 17 are local ones), there is only ONE local TYPE declaration and only 8 local CONST declarations.
Since this example has been cited several times now: I think that it tells more about the programming style preferred by Niklaus Wirth than about the actual value of local declarations. Wirth tries very hard to avoid so called "type explosion". Therefore, he rather declares a single record with very generally usable fields than a hierarchy of record types. And fewer type declaration in total also means fewer local ones. Richard
participants (2)
-
Andreas Pirklbauer -
Richard Hable