Oberon System 3 on WIndows: Why does the step size in FOR-loop have to be a constant expression?
On page 273 of "Programming in Oberon" Wirth and Reiser write: FORStatement = "FOR" ident ":=" expression "TO" expression ["BY" ConstExpression "DO"] StatementSequence "END" And indeed when I try to put a variable as step size, the compiler doesn't like it. This means I cannot write reusable code, which allows to be executed under different conditions with different step sizes. I am sure, there is some reasoning behind this, but I find it kind-off inconvenient. Regards, Dieter
Use WHILE if step size is variable. Jörg
Am 09.12.2018 um 17:54 schrieb Dieter <d.gloetzel@web.de>:
On page 273 of "Programming in Oberon" Wirth and Reiser write:
FORStatement = "FOR" ident ":=" expression "TO" expression ["BY" ConstExpression "DO"] StatementSequence "END" And indeed when I try to put a variable as step size, the compiler doesn't like it.
This means I cannot write reusable code, which allows to be executed under different conditions with different step sizes.
I am sure, there is some reasoning behind this, but I find it kind-off inconvenient.
Regards, Dieter
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
Joerg: Removing an increment "BY" from a FOR loop looks like a highly questionable optimization to me. I am not sure if the person who made this optimization wrote a lot of data processing code, or any at all. Stepping by an increment other than "1" is a common practice in data processing. Wojtek ________________________________________ From: Oberon [oberon-bounces@lists.inf.ethz.ch] on behalf of Jörg Straube [joerg.straube@iaeth.ch] Sent: Sunday, December 9, 2018 4:15 PM To: ETH Oberon and related systems Subject: Re: [Oberon] Oberon System 3 on WIndows: Why does the step size in FOR-loop have to be a constant expression? Use WHILE if step size is variable. Jörg
Am 09.12.2018 um 17:54 schrieb Dieter <d.gloetzel@web.de>:
On page 273 of "Programming in Oberon" Wirth and Reiser write:
FORStatement = "FOR" ident ":=" expression "TO" expression ["BY" ConstExpression "DO"] StatementSequence "END" And indeed when I try to put a variable as step size, the compiler doesn't like it.
This means I cannot write reusable code, which allows to be executed under different conditions with different step sizes.
I am sure, there is some reasoning behind this, but I find it kind-off inconvenient.
Regards, Dieter
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.inf.ethz.ch_mailman_listinfo_oberon&d=DwIGaQ&c=kbmfwr1Yojg42sGEpaQh5ofMHBeTl9EI2eaqQZhHbOU&r=uUiA_zLpwaGJIlq-_BM9w1wVOuyqPwHi3XzJRa-ybV0&m=-G2bXhw98iRu7ApZv0lM95cj2z2RIfyOYI0lIM_6CoQ&s=JWl3Y6-mrBhYQ2AxFHiCKyuGonRS9IhQi7tVh-gwExc&e=
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.inf.ethz.ch_mailman_listinfo_oberon&d=DwIGaQ&c=kbmfwr1Yojg42sGEpaQh5ofMHBeTl9EI2eaqQZhHbOU&r=uUiA_zLpwaGJIlq-_BM9w1wVOuyqPwHi3XzJRa-ybV0&m=-G2bXhw98iRu7ApZv0lM95cj2z2RIfyOYI0lIM_6CoQ&s=JWl3Y6-mrBhYQ2AxFHiCKyuGonRS9IhQi7tVh-gwExc&e=
Wojtek «BY» is still in the language. It does not have to be 1. You can increment by 2, 3, 4, 12, 59 whatever, but it has to be constant. If it is a variable take WHILE. Jörg Gesendet von Mail für Windows 10 Von: Skulski, Wojciech Gesendet: Montag, 10. Dezember 2018 01:24 An: ETH Oberon and related systems Betreff: Re: [Oberon] Oberon System 3 on WIndows: Why does the step sizein FOR-loop have to be a constant expression? Joerg: Removing an increment "BY" from a FOR loop looks like a highly questionable optimization to me. I am not sure if the person who made this optimization wrote a lot of data processing code, or any at all. Stepping by an increment other than "1" is a common practice in data processing. Wojtek ________________________________________ From: Oberon [oberon-bounces@lists.inf.ethz.ch] on behalf of Jörg Straube [joerg.straube@iaeth.ch] Sent: Sunday, December 9, 2018 4:15 PM To: ETH Oberon and related systems Subject: Re: [Oberon] Oberon System 3 on WIndows: Why does the step size in FOR-loop have to be a constant expression? Use WHILE if step size is variable. Jörg
Am 09.12.2018 um 17:54 schrieb Dieter <d.gloetzel@web.de>:
On page 273 of "Programming in Oberon" Wirth and Reiser write:
FORStatement = "FOR" ident ":=" expression "TO" expression ["BY" ConstExpression "DO"] StatementSequence "END" And indeed when I try to put a variable as step size, the compiler doesn't like it.
This means I cannot write reusable code, which allows to be executed under different conditions with different step sizes.
I am sure, there is some reasoning behind this, but I find it kind-off inconvenient.
Regards, Dieter
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.inf.ethz.ch_mailman_listinfo_oberon&d=DwIGaQ&c=kbmfwr1Yojg42sGEpaQh5ofMHBeTl9EI2eaqQZhHbOU&r=uUiA_zLpwaGJIlq-_BM9w1wVOuyqPwHi3XzJRa-ybV0&m=-G2bXhw98iRu7ApZv0lM95cj2z2RIfyOYI0lIM_6CoQ&s=JWl3Y6-mrBhYQ2AxFHiCKyuGonRS9IhQi7tVh-gwExc&e=
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.inf.ethz.ch_mailman_listinfo_oberon&d=DwIGaQ&c=kbmfwr1Yojg42sGEpaQh5ofMHBeTl9EI2eaqQZhHbOU&r=uUiA_zLpwaGJIlq-_BM9w1wVOuyqPwHi3XzJRa-ybV0&m=-G2bXhw98iRu7ApZv0lM95cj2z2RIfyOYI0lIM_6CoQ&s=JWl3Y6-mrBhYQ2AxFHiCKyuGonRS9IhQi7tVh-gwExc&e= -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
Joerg: oh, I see. On reading the message I thought that the step was removed. I agree that the most common pattern is a constant step. Wojtek ________________________________________ From: Oberon [oberon-bounces@lists.inf.ethz.ch] on behalf of Jörg Straube [joerg.straube@iaeth.ch] Sent: Sunday, December 9, 2018 7:27 PM To: ETH Oberon and related systems Subject: Re: [Oberon] Oberon System 3 on WIndows: Why does the step sizein FOR-loop have to be a constant expression? Wojtek «BY» is still in the language. It does not have to be 1. You can increment by 2, 3, 4, 12, 59 whatever, but it has to be constant. If it is a variable take WHILE. Jörg Gesendet von Mail<https://go.microsoft.com/fwlink/?LinkId=550986> für Windows 10 Von: Skulski, Wojciech<mailto:skulski@pas.rochester.edu> Gesendet: Montag, 10. Dezember 2018 01:24 An: ETH Oberon and related systems<mailto:oberon@lists.inf.ethz.ch> Betreff: Re: [Oberon] Oberon System 3 on WIndows: Why does the step sizein FOR-loop have to be a constant expression? Joerg: Removing an increment "BY" from a FOR loop looks like a highly questionable optimization to me. I am not sure if the person who made this optimization wrote a lot of data processing code, or any at all. Stepping by an increment other than "1" is a common practice in data processing. Wojtek ________________________________________ From: Oberon [oberon-bounces@lists.inf.ethz.ch] on behalf of Jörg Straube [joerg.straube@iaeth.ch] Sent: Sunday, December 9, 2018 4:15 PM To: ETH Oberon and related systems Subject: Re: [Oberon] Oberon System 3 on WIndows: Why does the step size in FOR-loop have to be a constant expression? Use WHILE if step size is variable. Jörg
Am 09.12.2018 um 17:54 schrieb Dieter <d.gloetzel@web.de>:
On page 273 of "Programming in Oberon" Wirth and Reiser write:
FORStatement = "FOR" ident ":=" expression "TO" expression ["BY" ConstExpression "DO"] StatementSequence "END" And indeed when I try to put a variable as step size, the compiler doesn't like it.
This means I cannot write reusable code, which allows to be executed under different conditions with different step sizes.
I am sure, there is some reasoning behind this, but I find it kind-off inconvenient.
Regards, Dieter
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.inf.ethz.ch_mailman_listinfo_oberon&d=DwIGaQ&c=kbmfwr1Yojg42sGEpaQh5ofMHBeTl9EI2eaqQZhHbOU&r=uUiA_zLpwaGJIlq-_BM9w1wVOuyqPwHi3XzJRa-ybV0&m=-G2bXhw98iRu7ApZv0lM95cj2z2RIfyOYI0lIM_6CoQ&s=JWl3Y6-mrBhYQ2AxFHiCKyuGonRS9IhQi7tVh-gwExc&e=
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.inf.ethz.ch_mailman_listinfo_oberon&d=DwIGaQ&c=kbmfwr1Yojg42sGEpaQh5ofMHBeTl9EI2eaqQZhHbOU&r=uUiA_zLpwaGJIlq-_BM9w1wVOuyqPwHi3XzJRa-ybV0&m=-G2bXhw98iRu7ApZv0lM95cj2z2RIfyOYI0lIM_6CoQ&s=JWl3Y6-mrBhYQ2AxFHiCKyuGonRS9IhQi7tVh-gwExc&e= -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.inf.ethz.ch_mailman_listinfo_oberon&d=DwQFaQ&c=kbmfwr1Yojg42sGEpaQh5ofMHBeTl9EI2eaqQZhHbOU&r=uUiA_zLpwaGJIlq-_BM9w1wVOuyqPwHi3XzJRa-ybV0&m=PxDdkIwYEd2P7wfAnIGBMlqpS_fbE8jiNSIW8cazuqs&s=Gn78hTZsEUa-LRXDWKENkwH0-NhAp72E_guk_BdxVKs&e=>
participants (3)
-
Dieter -
Jörg Straube -
Skulski, Wojciech