from time to time while working with attribute methods that got created with the "::METHOD xyz ATTRIBUTE" directive I would like to use the setter method in cascading messages, like:
... ::method bufferSize attribute ... say "current bufferSize is:" someObject~bufferSize -- using getter method someObjectbufferSize=1024 -- using setter method "bufferSize=" ... some code ... someObject~~"bufferSize="(2048)~~readDataFromSource -- using setter method explicitly, need for quotes!
At the moment it is needed to write the quotes around the setter method as it contains the equals operator (which makes it possible to get the syntax sugar). However, what I would like to be able in the latter case is to write the following:
someObject~~bufferSize(2048)~~readDataFromSource -- using the getter method to set a value alternatively
This could be achieved, if the generatead getter code for the attribute method directive "xyz" would be generated as such:
expose xyz if arg()=1 then -- if exactly one argument, assume a set operation and use it use arg xyz return xyz
Personally, I started to implement this behaviour on getter methods that I need to write by hand, as I need to supply a customized setter method (and therefore need to implement the getter method anyway), as coding cascading messages comes in a little bit "handier"/"easier"/"Rexx'ish".
The above example could then look like:
... ::method bufferSize attribute ... say "current bufferSize is:" someObject~bufferSize -- using getter method someObjectbufferSize=1024 -- using setter method "bufferSize=" ... some code ... someObject~~bufferSize(2048)~~readDataFromSource
No present code would be affected/broken by introducing this ability in a future version of ooRexx.