#124 Enhancing ATTRIBUTE METHODs ...

Rejected
closed
None
5
2012-08-14
2007-03-17
No

Hi there,

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.

---rony

Discussion

  • Rick McGuire

    Rick McGuire - 2007-06-12

    Logged In: YES
    user_id=1125291
    Originator: NO

    While this might be a useful enhancement, this will have a side effect of introducing some inconsistencies into the language. Attribute methods are just a short hand for simple accessors. They can be created either using the attribute or by hand coding. There's no way to enforce that an assigner method have a return value, and many assigner methods don't. For example, one could easily implement a construct like

    a~foo = "Fred"

    using a class with an attribute method or with a directory. They are polymorphic, but the directory assignment does not return a value. Exploiting this feature imposes a burden on the programmer that he not only know exactly what class he's dealing with, but the also the implementation of the assignment method to understand when cascading is possible or not. This introduces an unenforceable paradigm to the language that will be both difficult to document and difficult to use, with no real net benefit or enhancement to the language.

     
  • Rick McGuire

    Rick McGuire - 2007-06-12

    Logged In: YES
    user_id=1125291
    Originator: NO

    Notice: This RFE is slated to be rejected.

    Reason: See the RFE item in the SourceForge Tracker system for the rejection reason.

    To appeal this rejection please contact the Appeals Committee via Mr. Chip Davis

    oorexx-rfe-appeals@oorexx.org

    All further correspondence on this RFE should be directed to the Appeals Committee and MUST include this RFE number.

    The decision of the Appeals Committee is final.

     


Anonymous

Cancel  Add attachments