On 6/16/2024 1:57 PM, Jeremy Nicoll wrote:
On Sun, 16 Jun 2024, at 13:42, Gilbert Barmwater wrote:
But it doesn't close the file.  And there is no way to close it after
that statement since there is no reference to the stream object.  Now,
in most cases, not closing the stream is not a problem as ooRexx will do
it when the program ends.  But if you need to access the same file again
later in the program, having the stream still open is problematic, no?
Does the single-liner approach also allow one to cope with not being
able to open the file in the first place?
No, the single-line approach doesn't enable testing for that situation.  However, if the stream doesn't open, the arrayin message should fail (not tested however). For situations where that may be the case - a failed open - your traditional approach (below) is certainly more robust than the single-liner. But in many situations, the overhead of testing the result of every operation can 1) affect performance and 2) make understanding the program logic more difficult. But it is up to the programmer how "defensive" they want to be when coding.
Maybe I'm too wedded to traditional methods?  Test if opening the
stream worked, decide what to do if it failed, then if it worked go on
to read/write the data, finally close it.

--
Gil Barmwater
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to