Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Maybe they are taking other languages into consideration. For example, to someone with a PHP background, this looks like a property:

    my $foo = $obj->bar;

    This looks like a method:

    my $foo = $obj->bar();

    I think the parentheses universally indicate a function or method, so that might be what they mean by clarity.

  • Sorry Geoff, I'm in total agreement with this style guideline. I find it much easier to scan the code when the method calls end in (). I find it especially good in cases where they are chained.
    • ugh... it's chaining where I find them the most superfluous
        my $val = Foo->new->attribute->format;
      just feels much more idiomatic to me than
        my $val = Foo->new()->attribute()->format();
      but ok, you're a reasonable guy, so I'll give in :)
      • Imagine a mixed-case like this:

        my $val = Foo->new->{attribute}->format->{id};

        It can get confusing quickly, especially when people do that horrible "return yourself" method chaining that SOAP-Lite uses. I know I'm in the minority on this though. I just don't think there's any advantage to leaving them off, and it makes your code less consistent.
  • A sub is a property is a sub. What about when using the :lvalue attributes; as evil as they are?

    sub value : lvalue {
        my $this = shift;
        $this->{VALUE};
    };

    Would you put the parens here:

    my $value = $self->name();

    but not here:

    $self->name = 'Chris';

    or leave it

    $self->name() = 'Chris';

  • ...make maintainance easier.

    In this case, that may make the code more greppable. So you don't have "->foobar" results when you grep for "->foo" for example. (Note that I and my shop both disagree with this particular guideline :)

  • Is that at least that style item can be automated by perltidy.

    Oh wait, I'm dreaming about the PPI automanipulatification of Perl::Style (or perhaps you'd call it Perl::MyWay)...

    In any case I REALLY need to get around to getting that written. :/