are automatic and syntactically transparent accessor methods.
For example, in Visual Fox Pro 6, if a method named property_Assign() exists, this method fires automatically when property is modified. If a method named property_Access() is defined, this method fires automatically when property is read. The property_Assign() and property_Access() methods, if they exist, are responsible for completing the transaction and circularities are preempted by the class internals.
Moreover, if a method named THIS_Access() is defined, this method fires for every property read, every property write, and every method call. This_Access() should return an object instance (usually THIS) that will handle the message. Think of this as a pre-hook for all inbound messages destined to an instance.
An example, in Visual Fox Pro 6 code:
x= CREATE("Foo") x.Caption= "this is lowercase" ?x.Caption && echoes "The Caption is: THIS IS LOWERCASE" ?x.Tag && echoes "Instance B"
DEFINE CLASS Foo AS Label Caption= "" Tag= "Instance A"
FUNCTION Caption_Assign( tcPassed) *-- Force caption to uppercase THIS.Caption= UPPER( tcPassed)
FUNCTION Caption_Access RETURN "The Caption is: " + THIS.Caption FUNCTION THIS.Access() LOCAL oBar oBar= CREATE( "Foo") oBar.Tag= "Instance B" RETURN oBar
ENDDEFINE
Is this cool, or what? Steven Black
Yes. I believe Sather Language (and Cecil Language and probably others) are similar, and Lisp Language variants (Common Lisp Object System) go way back. Another approach is to use a Meta Object Protocol to change what assignment etc mean for particular objects.
-- Dave Harris
See original on c2.com