in reply to Re^4: Module Announcement: Perl-Critic-1.01
in thread Module Announcement: Perl-Critic-1.01

Absolutely!

I think that the following is perfectly fine.
my ($x, $y) = @{ $obj->getPosition }
Depending upon the interface I think that it may be better to return a point reference or object rather than the xy coordinates themselves.
my $point = $obj->getPosition; do_something_with_point($point); printf "X is %.2f\n", $point->x; # or maybe $point->[0] - possibly bad # or maybe $point->{x} - probably bad # but really $point->x is the best

It is funny that you should use a geometry example. Many of the C or C++ libraries that I have seen that deal with graphics primitives prefer to pass around a point struct rather than the individual x or y.

Just because it is possible to make interchanged data as terse as possible doesn't mean it is the right thing to do.

my @a=qw(random brilliant braindead); print $a[rand(@a)];

Replies are listed 'Best First'.
Re^6: Module Announcement: Perl-Critic-1.01
by Jenda (Abbot) on Jan 29, 2007 at 22:43 UTC

    C or C++ cannot do anything better anyway. I think we can't convince each other so let's just hope we do not meet in one company and on the same project since this is one of the seemingly unimportant style issues that drive people crazy ;-)