Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: The purpose of prototypes in perl subroutines

by jjhorner (Hermit)
on Apr 13, 2005 at 11:32 UTC ( [id://447463]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re^2: The purpose of prototypes in perl subroutines
in thread The purpose of prototypes in perl subroutines

It is the same thing. Ask Nat Torkington, as that is what he calls it. Probably pure semantics, but either way, it is considered prototyping.
J. J. Horner 
CISSP,CCNA,CHSS,CHP,blah,blah,blah
  • Comment on Re^3: The purpose of prototypes in perl subroutines

Replies are listed 'Best First'.
Re^4: The purpose of prototypes in perl subroutines
by Joost (Canon) on Apr 13, 2005 at 11:45 UTC
Re^4: The purpose of prototypes in perl subroutines
by brian_d_foy (Abbot) on Apr 13, 2005 at 13:36 UTC

    Just because someone says something doesn't make it true. This isn't just semantics, either.

    Perhaps you give us the reference where you found Nat talking about this sort of prototype (article name or page number would work). IF you are talking about the "Cryptocontext" article, I think you've misunderstood something.

    --
    brian d foy <brian@stonehenge.com>
      Okay, Page 20, "Computer Science & Perl Programming", edited by Jon Orwant, Chapter 3, article title is Perfect Programming. I'm not making this up: Quote: When it's in effect, you can't use the bareword style of calling subroutines with no arguments (e.g. $result = mysub;) unless the subroutine was declared before its use, either with a prototype or with the subroutine definition itself. EndQuote:
      use strict 'subs'; print count; # an error with use strict 'subs' sub count; # prototyping count() is sufficient print count; # Not an error because Perl now knows about count()
      J. J. Horner 
      CISSP,CCNA,CHSS,CHP,blah,blah,blah
      

        The part that you called "prototyping" before is just the subroutine's forward definition. He gives two things there that get around 'use strict', and the one you used wasn't the one with prototypes.

        The very first example in perlsub tells you which one you used:

        To declare subroutines: sub NAME; # A "forward" declaration. sub NAME(PROTO); # ditto, but with prototypes
        --
        brian d foy <brian@stonehenge.com>

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://447463]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.