Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^4: Tao Perl Ching - The Scripture of the Way of Perl

by legato (Monk)
on Jan 20, 2005 at 19:24 UTC ( [id://423772]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Tao Perl Ching - The Scripture of the Way of Perl
in thread Tao Perl Ching - The Scripture of the Way of Perl

There are good reasons for many of those things. Vars begins with an upper-case V because vars is a Perl reserved word. All the other functions use lower-first casing, so better to make the one exception than change the entire module's syntax.

The prefixed minus is familiar to me from another language (I can't remember which, now) -- it's not an attempt to make them look like shell arguments, but rather a very common style; I suspect the author(s) of CGI.pm were used to using and seeing that style for named parameters. Because of this, when my functions accept named parameters, I use Params::Validate to normalize the keys, allowing but not requiring the prefixed minus.

Anima Legato
.oO all things connect through the motion of the mind

  • Comment on Re^4: Tao Perl Ching - The Scripture of the Way of Perl

Replies are listed 'Best First'.
Re^5: Tao Perl Ching - The Scripture of the Way of Perl
by Juerd (Abbot) on Jan 20, 2005 at 22:02 UTC

    There are good reasons for many of those things. Vars begins with an upper-case V because vars is a Perl reserved word.

    It may be a reason, but it certainly is not a GOOD reason. It's an awful one. If the name you want is taken, then invent another name! Don't find alternative ways to write the same thing for that WILL cause confusion and WILL look ugly.

    It is not even true. "vars" is not a reserved Perl word. There is a module called vars, but use is not the context. The context is a sub/method name, and you can without any trouble call that &vars:

    use strict; use warnings; sub vars { 1 + 1 } print vars; print main->vars;

    I use Params::Validate to normalize the keys, allowing but not requiring the prefixed minus.

    The only reason a minus is needed or wanted is wanting to allow a combination of positional and named arguments. Allowing a minus is nice for people who insist on consistent style (but those people should prepare for re-coding CPAN entirely), but IMnsHO it's a waste of CPU cycles to look for them.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://423772]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-24 04:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found