Re:Perl - the Detroit of scripting languages
by marpmarpmar on Wednesday July 31, 2013 @04:31PM
(#6136638)
That example doesn't show it very well. To be clear: The intended advantage is: Parens are optional. That permits syntax like the following to be implemented in pure Perl without changing the parser:
If parens were mandatory, it would need look like this:
try(
sub {
die "foo";
}
catch(
sub {
warn "caught error: $_";
}
)
);
Having the nicer form in the first example is possible only because sigils are mandatory, along with auto-flattening variables and easy code highlighting.
As for the example, with mandatory parens it would look like this:
w = qq_mult( ConjugateQ, qv_mult( RotationQ, Vector ) );
In production i'd write it like this:
my $W = qq_mult $ConjugateQ, qv_mult( $RotationQ, $Vector );
That gives a nice balance between a low number of parens, and clarity of intent.
As for the example, with mandatory parens it would look like this:
In production i'd write it like this: That gives a nice balance between a low number of parens, and clarity of intent.