Intermediate scopes in Oberon-07
> > Can you point to an example in Project Oberon 2013 which > > clearly illustrates what you mean by 'it may make assumptions > > which only make sense in the context of the caller'. > >
Sorry, don't know the Project Oberon source by heart. ;)
Well, since access to intermediate objects (constants, types, variables) is now no longer allowed since the most recent (2016) change to the Oberon language spec, there cannot really be ANY assumptions anymore which ONLY make sense in the context of the caller ... since the “context” itself can no longer be accessed ;-) The only remaining POSSIBLE assumption would therefore have to be something that specifically has to do with the way the CODE of the surrounding code is implemented. Of the 17 local procedures (of 850 total) in the Oberon system, I have not found one that meets that description.
On 2018-02-24 22:16, Andreas Pirklbauer wrote:
Of the 17 local procedures (of 850 total) in the Oberon system, I have not found one that meets that description.
I wonder about the assumption that the current implementation of the Oberon System is somehow the only reference to decide about the necessity or utility of features in the Oberon programming language. We all know that Wirth designed the Oberon System as a tool for teaching, and the Oberon programming language as tool for implementing this system. Also, when leaving out features in Oberon compared to Modula-2 (e.g. co-routines), he clearly stated that this does not mean that the feature itself is unnecessary, but that he did not need it for the implementation of this system. Nevertheless, Oberon is certainly a general purpose programming language, and it would be a shame to only use it for a single project. Thus, unless a feature actually leads to bad programming, like the EXIT statement or the RETURN statement at arbitrary positions within a procedure, there is no need to remove it from all alternative implementations and languages descendents, just because the current version of the Oberon language definition does not contain it anymore. Richard
...this system. Also, when leaving out features in Oberon compared to Modula-2 (e.g. co-routines), he clearly stated that this does not mean that the feature itself is unnecessary, but that he did not need it for the implementation of this system.
Co-routines can be implemented as MODULE. It does not need to be part of the language. br Jörg
I have 4 - 5 books about Compilers in Pascal and Modula-2 and the procedures Term, Factor and SimpleExpression are *always* nested inside Expression. But they aren't in Project Oberon. Are these authors just fools because they used a such (in your opinion) useless technique? I don't think so. Saying more, these nested procedures don't even need intermediate global procedures, so they can be nested also in Oberon-07 (2016). The parser of expressions is a very GOOD example where nested procedures are ELEGANT and makes sense. Factor, Term and SimpleExpression don't make any sense in the global scope. (* This code is properly formatted with a fixed-width font *) PROCEDURE Expression(...); PROCEDURE SimpleExpression(...); PROCEDURE Term(...); PROCEDURE Factor(...); BEGIN (* Strictly locals/globals : Factor, Expression. *) (* Intemediate globals : Term, SimpleExpression. *) (* Used : Factor, Expression. *) END Factor; BEGIN (* Term *) (* Strictly locals/globals : Term, Factor, Expression. *) (* Intermediate globals : SimpleExpression. *) (* Used : Factor. *) END Term; BEGIN (* SimpleExpression *) (* Strictly locals/globals : SimpleExpression, Term, Expression. *) (* Intermediate globals : (none) *) (* Used : Term. *) END SimpleExpression; BEGIN (* Expression *) (* Strictly locals/globals : SimpleExpression, Expression. *) (* Intermediate globals : (none) *) (* Used : SimpleExpression. *) END Expression;
Diego As you know Expression (indirectly) calls Factor, and Factor calls Expression. There might be more but I know THREE different techniques how to solve this circular reference, what to declare first 1) Nesting, with the compiler „problem“ of static link 2) Forward reference with the compiler „problem" of fixing the jump 3) Procedure variables. In the compiler, this comes for free. 3) is now the way how ProjectOberon does it. Personally, I find it quite appealing. br Jörg
Am 25.02.2018 um 01:12 schrieb Diego Sardina <dsar@eml.cc>:
I have 4 - 5 books about Compilers in Pascal and Modula-2 and the procedures Term, Factor and SimpleExpression are *always* nested inside Expression. But they aren't in Project Oberon. Are these authors just fools because they used a such (in your opinion) useless technique? I don't think so.
Saying more, these nested procedures don't even need intermediate global procedures, so they can be nested also in Oberon-07 (2016). The parser of expressions is a very GOOD example where nested procedures are ELEGANT and makes sense. Factor, Term and SimpleExpression don't make any sense in the global scope.
(* This code is properly formatted with a fixed-width font *)
PROCEDURE Expression(...);
PROCEDURE SimpleExpression(...);
PROCEDURE Term(...);
PROCEDURE Factor(...); BEGIN (* Strictly locals/globals : Factor, Expression. *) (* Intemediate globals : Term, SimpleExpression. *) (* Used : Factor, Expression. *) END Factor;
BEGIN (* Term *) (* Strictly locals/globals : Term, Factor, Expression. *) (* Intermediate globals : SimpleExpression. *) (* Used : Factor. *) END Term;
BEGIN (* SimpleExpression *) (* Strictly locals/globals : SimpleExpression, Term, Expression. *) (* Intermediate globals : (none) *) (* Used : Term. *) END SimpleExpression;
BEGIN (* Expression *) (* Strictly locals/globals : SimpleExpression, Expression. *) (* Intermediate globals : (none) *) (* Used : SimpleExpression. *) END Expression; -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
The question is not „fool“ yes or no. Look at NW, he used all three techniques in his compilers over time. In my point of view, you can see it as kind of evolution in thinking. The BNF productions of the language definition does not know nesting. If the language designer wants to reuse (for whatever reason) for example the production „SimpleExpression“ somewhere outside of the Expression-Term-Factor chain, you suddenly can’t implement it with nesting anymore. From this point of view, mapping every BNF production to a top level procedure seems straight forward. br Jörg
Am 25.02.2018 um 08:42 schrieb Jörg <joerg.straube@iaeth.ch>:
Diego
As you know Expression (indirectly) calls Factor, and Factor calls Expression. There might be more but I know THREE different techniques how to solve this circular reference, what to declare first 1) Nesting, with the compiler „problem“ of static link 2) Forward reference with the compiler „problem" of fixing the jump 3) Procedure variables. In the compiler, this comes for free.
3) is now the way how ProjectOberon does it. Personally, I find it quite appealing.
br Jörg
Am 25.02.2018 um 01:12 schrieb Diego Sardina <dsar@eml.cc>:
I have 4 - 5 books about Compilers in Pascal and Modula-2 and the procedures Term, Factor and SimpleExpression are *always* nested inside Expression. But they aren't in Project Oberon. Are these authors just fools because they used a such (in your opinion) useless technique? I don't think so.
Saying more, these nested procedures don't even need intermediate global procedures, so they can be nested also in Oberon-07 (2016). The parser of expressions is a very GOOD example where nested procedures are ELEGANT and makes sense. Factor, Term and SimpleExpression don't make any sense in the global scope.
(* This code is properly formatted with a fixed-width font *)
PROCEDURE Expression(...);
PROCEDURE SimpleExpression(...);
PROCEDURE Term(...);
PROCEDURE Factor(...); BEGIN (* Strictly locals/globals : Factor, Expression. *) (* Intemediate globals : Term, SimpleExpression. *) (* Used : Factor, Expression. *) END Factor;
BEGIN (* Term *) (* Strictly locals/globals : Term, Factor, Expression. *) (* Intermediate globals : SimpleExpression. *) (* Used : Factor. *) END Term;
BEGIN (* SimpleExpression *) (* Strictly locals/globals : SimpleExpression, Term, Expression. *) (* Intermediate globals : (none) *) (* Used : Term. *) END SimpleExpression;
BEGIN (* Expression *) (* Strictly locals/globals : SimpleExpression, Expression. *) (* Intermediate globals : (none) *) (* Used : SimpleExpression. *) END Expression; -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
On Sun, Feb 25, 2018, at 9:35 AM, Jörg wrote:
The question is not „fool“ yes or no. Look at NW, he used all three techniques in his compilers over time. In my point of view, you can see it as kind of evolution in thinking.
This is not evolution, this is cost-benefit trade-off. There is a level of acceptability and the use of procedure variables is not (for me). But Wirth accepted this trade-off. Forward reference add a bit of complexity in a single-pass the compiler, that's true, but if you look at OP2 sources it's on an acceptable level. But if you look at Active Oberon compiler where objects defined later in the source text may be used, the parser decisely worsened in readability and increased in size. This is unacceptable on every front, although a very brave work.
On Sun, Feb 25, 2018, at 8:42 AM, Jörg wrote:
1) Nesting, with the compiler „problem“ of static link
As I shown before, these procedures really don't need to access intermediate objects. Intermediate variables can be passed as parameters.
2) Forward reference with the compiler „problem" of fixing the jump
In my personal taste I always disliked forward reference.
3) Procedure variables. In the compiler, this comes for free.
3) is now the way how ProjectOberon does it. Personally, I find it quite appealing.
Appealing? :-) We have a really different taste about source code then. In the past I never saw procedure variables as a solution for circular reference, but at this point I prefer forward reference. Also they don't really come for free especially in runtime, it is another level of indirection and they prevent the compiler to inline them. I'm surprised that this is proposed as "a general solution" by Wirth
participants (4)
-
Andreas Pirklbauer -
Diego Sardina -
Jörg -
Richard Hable