Thread View: comp.lang.oberon
1 messages
1 total messages
Started by Mike Griebling
Mon, 15 Apr 1996 10:38
Re: Oberon's FOR
Author: Mike Griebling
Date: Mon, 15 Apr 1996 10:38
Date: Mon, 15 Apr 1996 10:38
33 lines
1849 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads