Not when dealing with objects.
my $paco = $foo->bar; Is this a scalar or a call to a class method with no paramaters? Let's sift through the code to find out, oh joy!
My main point is that subroutines are doing the majority of the work in a block of code. () at the end makes them stick out. Hi there! Being almost blind, I love having these handy little pointers in the code that I'm looking at. The fact that it the rule of law in other languages means that my subconsious is naturally drawn to them. Just because you can do something different than other languages doesn't mean that you have to.
update: I just knew that I would put my foot in my mouth when I start talking about OO perl. ++ to both responses. (I still hate it bareword methods. :-P) | [reply] |
my $snafu=$foo->{bar};
The placement of the subs at the top of a package does _not_ prevent you from using the parens style, whereas placing at the bottom _does_ prevent you from using the bareword style. Whereas the placment of subs has an indirect effect on error rates. Thus there is still no reason not to employ best practice.
Yves / DeMerphq
--
When to use Prototypes?
Advanced Sorting - GRT - Guttman Rosler Transform | [reply] [d/l] [select] |
my $paco = $foo->bar;
Is this a scalar or a call to a class method with no paramaters? Let's sift through the code to find out, oh joy!
Let's sift indeed:
my $paco =
Ah, we're creating a lexically scoped scalar called $paco
$foo
It has something to do with another scalar, called $foo
->
The arrow indicates we're either going to dereference, or have method call.
bar
No [] or {}, so it's a method call. Neato, we're using objects!
But we can't see whether $foo is a scalar holding a blessed reference (better known as object) or a scalar holding a package name. That's only because it's called $foo, because a good name would tell us.
And do you really put package names in scalars and then use those to call class methods? It's ugly, just like using soft references.
44696420796F7520732F2F2F65206F
7220756E7061636B3F202F6D736720
6D6521203A29202D2D204A75657264
| [reply] [d/l] [select] |