Re: kanjidic parser in Perl?



David Alexander Ranvig wrote:
"John J. Chew, III" <jjchew@xxxxxxxxxxxxxxxx> writes:

| > sub kdic::parse_entry
| | sub parse_entry ($) {
| | Always use prototypes.


I believe this advice to be counterproductive.

Tom Christiansen once posted a nice write-up of "prototypes" in perl:

Thanks for posting that. His main beef with prototypes is that they give programmers a false sense of security, because they only catch argument type and number errors under some circumstances and not others.

I should have suggested to Ben in my first message, as I did in my
second, that he make a point of including prototyped sub declarations
at the beginning of each file.  Doing so solves one of Tom's problems
by ensuring that prototype checking takes place right from the start
of the file, including uses of the sub before it is defined.

I myself have found prototypes to be extremely valuable, and would
no more omit them than I would code without "use strict" or
"use warnings".  It could be because of sloppy coding habits:
I'm almost always wrong as to how many arguments the final version
of a sub is going to want, and I find it convenient to have Perl
tell me when I've been inconsistent.

John
--
John Chew <jjchew@xxxxxxxxxxxxxxxx> http://www.poslfit.com
.



Relevant Pages

  • Re: Sweetest Accessor?
    ... care for mixing shift and @_ in the same sub -- visually. ... That isn't tied to shifting. ... You can't throw prototypes into an OO design. ...
    (comp.lang.perl.misc)
  • Re: IO::Socket::INET on OSX or TCP stack problem
    ... just declaring vars outside a sub makes them static. ... SG> I am using perl -w - I dont usually, but while I am trying to figure ... SG> perl -w complains if you don't use prototypes. ... perl doesn't complain if you don't use prototypes. ...
    (comp.lang.perl.misc)
  • Re: why doesnt this argument list need a comma after the 1st argument?
    ... I'm reading this very interesting book on Perl (Effective Perl Programming ... that the anonymous subroutine does not require the "sub" keyword, ... Prototypes were introduced to allow you to write ... block (without a comma) like this, and treat it as an anon sub. ...
    (comp.lang.perl.misc)
  • Re: How to define a sub on the fly?
    ... > Anno Siegel wrote: ... They are the exception with sub definitions, ... use prototypes routinely with all subs. ...
    (comp.lang.perl.misc)