🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.oberon
Article #1333

Re: Oberon's FOR

#1333
From: Mike Griebling
Date: Mon, 15 Apr 1996 10:38
33 lines
1849 bytes
> Questions about the FOR statement in Oberon(-2):
> 
> Is the value of the counter variable undefined upon exiting the loop -
> as it is in Pascal and Modula-2?

In theory, the variable will have a defined value -- it just is not specified
what that value will be.

It is bad programming practice to rely on FOR variables having a certain
value outside FOR loops.
 
> Also, I've found that in both Oberon/F and Oberon V4 for Windows, I could 
> change the counter variable within the FOR loop. I thought this was illegal
> in Modula-2 - and that Oberon(-2)'s FOR loop was the same as Modula-2's.
> 
> Is it legal (as per the language definition) to change the counter within
> the loop?

The language definition says nothing about the counter being read-only
therefore I assume it is legal to change the counter value -- but, once
again, it is poor programming practice to do so.  Code relying on such
behaviour may also not be portable -- especially when optimizing Oberon-2
compilers hit the streets.

BTW, this is one of my pet peeves about Oberon-2.  I think the counter
variable should be implicitly defined only for the scope of the FOR
loop and should be read-only.

Regards,
	Michael
--------------------------------------------------------------
Michael Griebling, P. Eng.		grieblm@inforamp.net
Computer Inspirations			grieblm@trt.allied.com
Technical Details
Message-ID: <9604151006.AA00524@trt.allied.com>
Path: arc1-ca.pugleaf.net!inf.ethz.ch!oberon-news@inf.ethz.ch

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!inf.ethz.ch!oberon-news@inf.ethz.ch
From: grieblm@trt.allied.com (Mike Griebling)
Newsgroups: comp.lang.oberon
Subject: Re: Oberon's FOR
Date: 15 Apr 1996 12:38:24 +0200
Organization: Dept. Informatik, Swiss Federal Institute of Technology
Sender: server@inf.ethz.ch
Distribution: world
Message-ID: <9604151006.AA00524@trt.allied.com>
Reply-To: oberon-news@inf.ethz.ch
NNTP-Posting-Host: neptune.inf.ethz.ch
Originator: oberon-news@inf.ethz.ch