Re: which is better practice
From: Eric Schwartz (emschwar_at_pobox.com)
Date: 07/16/04
- Next message: Abigail: "Re: which is better practice"
- Previous message: Tassilo v. Parseval: "Re: which is better practice"
- In reply to: Abigail: "Re: which is better practice"
- Next in thread: Abigail: "Re: which is better practice"
- Reply: Abigail: "Re: which is better practice"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 15 Jul 2004 16:46:59 -0600
Abigail <abigail@abigail.nl> writes:
> Eric Schwartz (emschwar@pobox.com) wrote on MMMCMLXX September MCMXCIII
> __ my ($x, $y); $x = $y = 0; ?
>
> That's more typing. I like the ability to initialize in the same
> statement as I declare.
I do too, but in general, it's the declaring variables in the middle
of an expression (unless it's a for or while, in which case it feels
semantically to me like it's the beginning) has never felt right to
me.
> You need to get out more. ;-)
I won't deny that. :) But I still haven't ever seen it in the wild, as
it were.
> Just as I don't see a point in writing:
>
> my $i;
> $i = 0;
>
> I don't see the point of writing:
>
> my $opt;
> GetOptions "option=s" => \$opt;
If it were only one option, I might be pursuaded, but I've never used
GetOptions without at least four or five options; almost all my
scripts have --help, --verbose, --debug, and --silent. In that case,
my style would have
##############
# GLOBAL OPTIONS
##############
our ($opt_help, $opt_verbose, $opt_debug, $opt_silent);
##############
# Get command-line options
##############
GetOptions("help|h" => \$opt_help,
"verbose|v" => \$opt_verbose,
"debug|d:i" => \$opt_debug, # :i lets me specify debug levels
"silent|s" => \$opt_silent,
# more options here
);
I don't know that I can come up with a reason other than personal
preference for not declaring them together with the function call, but
it seems somehow more cluttered than the alternative. I'm glad,
though, that Perl gives us these *ahem* options.
-=Eric
-- Come to think of it, there are already a million monkeys on a million typewriters, and Usenet is NOTHING like Shakespeare. -- Blair Houghton.
- Next message: Abigail: "Re: which is better practice"
- Previous message: Tassilo v. Parseval: "Re: which is better practice"
- In reply to: Abigail: "Re: which is better practice"
- Next in thread: Abigail: "Re: which is better practice"
- Reply: Abigail: "Re: which is better practice"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|