I have a question/request concerning perl6 object properties.
I've done some work with .NET and They have come up with a really slick
way to handle object properties.
A typical property definition in VB.NET looks like:
Public Property propertyName() As String
Get
return aString
End Get
Set(ByVal Value As String)
' set value
End Set
End Property
You can use it like this:
oObj.description = sDescr ' calls setter
sDescr = oObj.description ' calls getter
This allows proper encapsulation of object properties while providing a
very clean interface. A corollary feature is that properties can map to
arbitrary values. I've written object property definitions that read
and write directly to relational databases, and Ive written read only
properties that abstract XPath queries to config files.
My main interest in the feature is using the assignment operator to
assign to object properties.
I posted a question to CLPM on how to do this with perl5 and we decided
to use an 'lvalue' attribute on the subroutine and then make the
returned lvalue in the sub a tied variable to intercept read/writes:
http://groups.google.com/groups?th=5489106ee6715c8e
It works, but its obviously slow and can get confusing for anything
moderately complex.
I just thought I would share this and see if anything similar can fit
in the perl6 OO syntax.
Todd W.