[Oberon] LONGINT, RETURN & etc.

Chris Burrows chris at cfbsoftware.com
Sat Jun 17 06:10:15 CEST 2017


> -----Original Message-----
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of
> Skulski, Wojciech
> Sent: Saturday, 17 June 2017 9:36 AM
> To: ETH Oberon and related systems
> Subject: Re: [Oberon] LONGINT, RETURN & etc.
> 
> 
> >Now the syntax
> >      "RETURN" (expression)
> > still exists but not as part of (statement). Due to this syntax
> change
> >it is only allowed to be used ONCE in a PROCEDURE block.
> >
> > Did this explanation help?
> 
> It did help, but it is not an explanation. It is a declaration. I
> read it as "for whatever reason RETURN is only allowed to be used
> ONCE in a PROCEDURE block". I will try to memorize.
> If I fail to memorize, the compiler will kindly remind me of the
> rule.
> 
> So OK, I take it that in the past I could write RETURN 1+2, and now I
> am allowed to write RETURN 3. Just another rule.
> It probably helps in writing a better compiler. I am fine with this.
> 

'1+2' is an expression so you can still write RETURN 1+2. You have always
been allowed to write RETURN 3. What you can't have is just RETURN without
an expression.

It is not just that you can only use a RETURN statement ONCE in a PROCEDURE
block; you can now ONLY use a RETURN statement at the END of a PROCEDURE.
i.e. you cannot exit from a procedure from some arbitrary point in its body.
The rule enforces the structured programming concept that in order to
develop reliable / testable programs each procedure 'should have only one
entry and one exit point'. 

The following article gives a passionate explanation of why this is so
important when developing large programs in real-world situations:

http://wiki.c2.com/?SingleFunctionExitPointPlease

I hope that makes it all clearer. While you are thinking about that you
might also like to think about why the Oberon 'LOOP' statement with multiple
'EXIT's was abolished at the same time. The arguments are very similar.

Regards,
Chris Burrows
CFB Software
http://www.astrobe.com






More information about the Oberon mailing list