Adding a / method to the File class would allow to write the following:
f = .File~new("/home/user/storage")
r = f / "examples" / "hello.rex" -- returns a new File object
This notation, similar to the one provided by Python's pathlib, is more readable than manual string concatenation and would automatically use the correct path separator on each platform.
Overloading of / should not cause any ambiguity, since neither a File object nor its string representation should ever be interpreted as a numeric string.
Anonymous
From Jochem Peelen:
Did you consider that in Windows the path separator is the \ (backslash)? The backslash is also the Rexx symbol for negating.
Thank you for the response. I think there might be a slight misunderstanding of the proposal.
I am not suggesting to use the backslash (
\) as an operator in Rexx code (which, as you pointed out, is the unary operator for negation).Instead, the proposed binary
/is strictly a path composition operator in code syntax across all operating systems. The resultingFileobject handles the OS-specific path separators internally when constructing the path string.As far as I know, this is the way Python's
pathlibworks on Windows.the
Fileobjectrwould have the following path:"dir/subdir/hello.rex"in Linux, Mac, BSD..."dir\subdir\hello.rex"in WindowsHere is a quick proof-of-concept class that implements this behavior:
Last edit: Salvador Parra Camacho 2026-08-04
Just a few thoughts on this proposal. I think that what threw me off initially was the choice for the operator - '/'. I'm a Windows guy so it struck me as a bit confusing at first. I think that perhaps a better choice might be '+' as it suggests that one is "adding" an element - folder or file name - to the path defining the .File object.
With that in mind I have put together the following bit of code that you can use now pending the (possible) implementation of this feature request. Some things to note: the code can be inserted into a program that needs this behavior or placed into its own file which can then be included via ::requires. The PUBLIC keyword on the CLASS statement is NOT needed if the code is in the using program (but it doesn't hurt) but is needed if the code is in a file included via ::requires. Second, I named the class File so that you don't have to remember another classname when you wish to use this feature. As a result, it "appears" that the File class has gained a new '+' method but in reality, .File now refers to a subclass of the Rexx-supplied File class. Of course, you can choose to name the class whatever you wish. The same goes for the choice of the operator; any binary operator would work just as well as '+'.