Andrew Savige wrote:

[...]

Naming. I wonder if your:

       { use_return => 1 },

is the recommended Perl style for named parameters? I thought not
until I noticed HTML::Parser uses this style. Alternatives are


I like this style.

CamelCase style (a la XML::Parser, for example):

{ UseReturn => 1 },


I think this is yucky. Its use is eschewed for variable names (perlstyle says that it's harder for non-native English speakers) so I don't see that it has any legitimate use for hash keys (which are nothing more than second-class variable names).

or dash-option style (a la CGI, for example):

{ -use_return => 1 },



I'm not too fond of this either. I've always felt that it's trying to emulate command line switches, poorly. It fails on "multi word" names. A longword switch should be written as --use-return, at least according to long-standing tradition. It grates on my nerves when I see switches that mix dashes and underscores like --use_return. That just feels wrong, as if the author isn't aware of prior art.


And so if you accept my hypotheses that --use-return is the Right Thing, then you can't specify that as a hash key bareword. Hence I judge it to be a failure.

So I would tend to consider that { use_return => 1 } is the preferred way. I certainly find it to be the most appealing from a visual point of view.

I'm damned if I can find a reference clearly stating which one of
these three styles is preferred. Can anyone point me to a reference
on this?



Nor can I, but my gut feeling is that most of the modules I use on a regular basis use the first form.


David



Reply via email to