develooper Front page | perl.perl6.language | Postings from May 2005

Re: $:attr vs $.:attr

Thread Previous | Thread Next
From:
Aaron Sherman
Date:
May 16, 2005 02:54
Subject:
Re: $:attr vs $.:attr
Message ID:
1116237249.31177.25.camel@markab
On Sun, 2005-05-15 at 19:18 +0200, Juerd wrote:
> Now:
> 	Declaration	Explicit	Implicit $_	$?SELF
> 	has $.var | 	$obj.var \	.var \		./var \
> 	has $:var |	$obj.:var \	.:var \		./:var \
> 
> Consistent:
>  	has $.var \	$obj.var \	.var \		./var \
>  	has $.:var \	$obj.:var \	.:var \		./:var \
> 
> See it yet? It's about consistency in the whole scheme, not the clarity
> of a single element.

I'm not sure I see that you changed anything other than changing "Old
way" to "Now", "Your proposal" to "Consistent", adding separator
characters between the columns, and removing the word "Implicit" from
the last column.

I'm still not seeing the problem. Counting down and then right, I read
those: "$." means attribute; "$:" means private attribute; "$x." means
accessor method; "$x.:" means private accessor method; and so on...

I think you're confusing the method glyph "." and the attribute glyph,
also "." in the first and second columns. Consistency would be to make
accessor methods use both the attribute and accessor glyphs "..", but
that would cause at least 4 problems that I can think of, so "." is a
nice simple thing to do. In the case of private accessor methods, most
of those reasons go away, so ".:" needn't be (and in fact can't be)
shortened.

All of the details aside, I simply don't see newbies getting all that
confused. For starters, there's no particular reason that they would
have to use private attributes all that often, and if they did, they
don't really EVER have to use accessor methods on them, though style
might nudge them in that direction, there's no real impact on
scalability the way there is with regular accessors (because every use
of the private accessor is local to the class definition).

Now, the one place I can see that you should ALWAYS use the private
attribute accessors is in roles. Here, it would be essential, as you
don't know what the composing class might want to do to that method, so
the only place that I see this being a big concern is in roles that have
private attributes. Certainly an edge case newbies won't contend with
all that often, yes?

> Note that it's not *implicit* $?SELF. "./" is a prefix operator that
> calls a method on $?SELF

That's picking nits. I know that, but was referring to the implicit use
of $?SELF regardless of the syntax one would have to employ in order to
use it explicitly.



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About