On Tue, Apr 20, 2004 at 01:15:24PM -0400, John Siracusa wrote: : With that "has" line alone, you auto-magically get an accessor that works : like this: : : $obj.foo # get value of $.foo : $obj.foo(5) # set $.foo = 5
I don't care what syntactic sugar you put underneath, but if you expose this interface to the user, it's fundamentally flawed. This is my argument from the Apocalypse, and it hasn't changed. It's wrong to introduce a fundamental asymmetry that breaks the contract that an accessor can be used as a variable. The arguments to an accessor should function as part of the "long name" of whatever it is you're setting, whether it's concrete or abstract. Some of those arguments may want to be optional, or have other weirdnesses that get introduced as your interface develops. Having an extra argument on the end just totally screws up that sort of extensibility. So do whatever you like to the declarations, but make sure you preserve the symmetry and extensibility of $obj.foo([EMAIL PROTECTED], *%NONSENSE) # get value of $.foo $obj.foo([EMAIL PROTECTED], *%NONSENSE) = 5 # set $.foo = 5 And while you're at it, make sure your syntactic sugar doesn't force people to duplicate the code to process [EMAIL PROTECTED] and *%NONSENSE in their getter and setter. Them's the specs. Larry