Feature Requests item #1098932, was opened at 2005-01-09 14:04
Message generated for change (Comment added) made by sahananda
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=684733&aid=1098932&group_id=119701
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Interpreter
Group: Next Release
Status: Pending
Resolution: Accepted
Priority: 5
Private: No
Submitted By: Rick McGuire (bigrixx)
Assigned to: Rick McGuire (bigrixx)
Summary: Improve syntax for defining attribute methods.
Initial Comment:
ooRexx has a handy syntax for exposing an object
internal variable as getter/setter accessor methods using
::method foo attribute
however, because of the way attributes are used, people
have a hard time thinking of them as "methods". They
are properties, not methods. So it would be nice if
the alternative syntax
::attribute foo were supported.
There are still some other problems here. For examply,
there's currently no means for defining read-only
properties. To do that, you need to drop down and
define an actual method for the property:
::method foo
expose foo
return foo
It would be nice to be able to code
::attribute foo readonly
Also, if setter logic requires some sort of validation,
then it become necessary to code both the setter and
getter methods. Additionally, the setter method gets
exposed to another bit of ugliness on the ::method
statement, the requirement to quote (and uppercase) the
method name to include the "="
::method "FOO="
C## and some versions of Javascript have a nice model
for something like this, allowing the property to be
defined, along with the getter/setter methods in place.
For example ooRexx could do something like this.
::attribute foo
::set
expose foo
use arg new
if datatype(.....)
::get
expose foo
.....
Either ::get or ::set can be optional. If not
specified, it will default to the automatically
generated method.
Question: Should ::get ::set methods implicitly expose
the instance variable of the same name?
----------------------------------------------------------------------
Comment By: Jon Wolfers (sahananda)
Date: 2007-09-22 05:58
Message:
Logged In: YES
user_id=667060
Originator: NO
Hi Rick,
While you're working in this area, one thing that I would find handy would
be to be able to declare several attributes in one single directive.
For instance, I have an object with 43 properties, I have 43 directives
like such:
::method error Attribute -- Database access error
::method baseRRP Attribute -- The current w:e baseprice
::method bomQty Attribute -- The number of this child in a bom
parent
::method bomsComplete Attribute -- The number of complete parents in
stock
::method bomSpares Attribute -- Boolean - incomplete children exist
::method category Attribute -- Department Code ' '|[A-Z]
::method categoryName Attribute -- Text Associated with Category
::method code Attribute -- Product code
and so on.
What would be nice would be able to declare them in a single directive
like this
::Attribute (error, baseRRP, bomQty, bomsComplete, bomSpares, category,
categoryName, code) [readonly]
::get -- if this is specified it should apply to all the Attributes
created by the above directive
::set -- if this is specified it should apply to all the Attributes
created by the above directive
What do you think?
Jon
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=684733&aid=1098932&group_id=119701
|