John M. Dlugosz wrote:
That seems to be saying that using the method-call form is preferred, as
it abstracts whether it is a real hard attribute or not.

Er, it is not so.

The $.foo notation is good not only for calling accessors, but also as a way to specify context when calling oneself's methods. Consider:

class Foo {
    method bar ($x, $y) { ... }
    method baz (
        $.bar: 1, 2; 3, 4;

Here we are simply typing $.bar as a shorthand of $(, and as @(, as well as supplying them with arguments; they do not mandate that there exists a "bar" attribute for our class.

In other words, there needs to be no real hard attribute "bar", no matter if you call the "bar" method as, $.bar(), or simply $.bar.


Reply via email to