[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: [PATCH lib/lib.pm 5.005_63] Removing use of vars.pm
Pete Jordan writes:
: Larry Wall wrote:
:
: > Martyn Pearce writes:
: >
: > : I wonder why? In comparison to the two above, I tend to go for
: > :
: > : my ($FOO, $BAR, $BAZ) = ("foo", "bar", "baz");
: > :
: > : being both concise and initializing.
: >
: > The problem with that is the separation between the variable name and
: > its value. And the more elements in the list, the worse it gets.
:
: I sometimes tend toward:
:
: my ($FOO, $BAR, $BAZ)=
: ("foo", "bar", "baz");
:
: in this situation.
As it happens,
my $FOO = "foo";
my $BAR = "bar";
my $BAZ = "baz";
is exactly the same number of characters, plus it allows simultaneously
for long values and many values, either of which can bankrupt your
approach.
Part of picking "my" in the first place was because it was short, and was
going to be used frequently. I've always Huffman[RIP]-coded my keywords.
So don't be scared to use multiple "my" keywords just because we yell
at people for saying
print "...";
print "...";
print "...";
print "...";
print "...";
About the only downside to the multiple "my" approach that I can see is
that it's multiple statements. Which means the debugger will stop on
each of them in single step (which might be a feature). Plus it might
run a teeny bit slower (which might not be a feature).
Larry
- References to:
-
Pete Jordan <pjordan1@email.mot.com>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]