Andy Wardley wrote:
>
> A key feature of this proposal is that object/class variable and
> methods are indistinguishable to the user.  The dot operator does
> the right thing to call a method (if defined), or instead access a
> variable, or follow a delegation reference, etc. i.e.
>
>     $foo.bar
>
> is something like (assuming a blessed hash)
>
>     UNIVERSAL::can($foo, 'bar') ? $foo->bar() : $foo->{'bar'};
>
> '->' and '::' won't do that, and shouldn't.  If we tried to overload
> '::' or '->' to be more magical then we would break things all over
> the place.

I don't understand.  Why don't you just have the class generator
automatically create an accessor method for every declared instance
variable and otherwise prevent access to the instance variable
except via said method?  Now methods and ivars look the same because
ivars *are* methods (accessor methods), from the perspective of the
class client.

This also means that if you define visibility constraints for
methods you more-or-less automatically get them for ivars, again
because ivars are only visible via their accessor methods.

That's how that Prothos::Class module I mentioned in a previous
message (about RFC 92) works.

Yours, &c, Tony Olekshy

Reply via email to