Regina Rexx 4.00 STREAM default changed to APPEND: making retry writes idempotent across interpreters
0 reputation · 23 Oct 2025, 18:44 UTC
0 reputation · 23 Oct 2025, 18:44 UTC
I maintain REXX scripts that run under both Regina Rexx and IBM Object REXX for Windows. The scripts use a programmer-written retry loop around output operations: if a write fails, the loop re-executes the same LINEOUT call against the same stream.
Regina Rexx 4.00 introduced a configurable STREAM default mode (APPEND versus REPLACE), while IBM Object REXX keeps the historic REPLACE default unless APPEND is passed explicitly on the STREAM call. This means the same retry loop can silently duplicate lines on one interpreter and overwrite prior content on another, depending on the version and configuration in effect.
The REXX language standard does not define a retry mechanism, so the loop is my own code and currently does not distinguish transient failures from permanent ones. I want one portable script that produces identical file contents regardless of interpreter, without assuming a particular STREAM default.
My questions:
LINEOUT idempotent when the default mode may be either APPEND or REPLACE?VERSION()) to branch its write logic?35775 reputation · 23 Oct 2025, 22:18 UTC
The Regina 4.00 STREAM default is not configurable per script. It is selected at interpreter startup, typically through a configuration file or environment variable, rather than through an in-language option. Because the setting is process-wide, a REXX script cannot change it with a directive inside the source file.
To make a retried LINEOUT idempotent across interpreters, do not rely on the default at all. Open the stream with an explicit mode argument every time, and keep that stream open across the retry loop.
There is no standard built-in function to query the active default mode at runtime. VERSION() identifies the interpreter and version, but it does not report the configured STREAM default. Runtime detection would require reading an external configuration file or environment variable whose name varies by distribution, which is fragile and non-portable.
The duplication or overwrite you observe is most likely caused by the retry loop re-executing LINEOUT against a stream that was opened implicitly under the interpreter default. On Regina 4.00, if the default is APPEND, a retry adds a second copy of the line. On IBM Object REXX, if the default is REPLACE, the retry overwrites the file with the same line, leaving only one copy but discarding any prior content.
What is well-established is that the STREAM command accepts an explicit mode keyword and that the mode in effect when the stream is opened governs subsequent LINEOUT writes until the stream is closed or reopened. What remains uncertain without checking your specific Regina 4.00 distribution is the exact name and location of the startup configuration file or environment variable that controls the default. Verify that against your platform’s documentation.
STREAM myfile, 'APPEND'
LINEOUT inside the retry loop without closing the stream. Because the mode was fixed at open time, every retry behaves identically regardless of the interpreter default.STREAM myfile, 'REPLACE'
LINEOUT myfile, firstLine
STREAM myfile, 'CLOSE'
STREAM myfile, 'APPEND'
/* retry loop here */
Test the pattern with a minimal script that writes a known line, forces a simulated failure, retries, and then inspects the file on both Regina 4.00 and IBM Object REXX.
/* test-retry.rexx */
fname = 'test.out'
STREAM fname, 'APPEND'
do i = 1 to 2
if i = 1 then do
say 'simulating failure'
iterate
end
LINEOUT fname, 'retry line'
end
STREAM fname, 'CLOSE'
Run the script twice on each interpreter and confirm that the file contains the expected number of lines. If duplication still occurs, the stream was likely reopened inside the loop under the default mode rather than being held open under the explicit mode.
Because the exact Regina configuration mechanism varies by build, treat any claim about a specific environment variable name as unverified until you confirm it in your installation.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.