in reply to Re^4: Read all the file path having text document
in thread Read all the file path having text document

Actually, I'm surprised too. I really meant omit the prototype specification on the sub declaration:

sub S {...}

rather than:

sub S ($) {...}

In other words, don't use the prototype at all is the fix rather than using a forward declaration. If the sub isn't prototyped the forward declaration isn't required.

A forward declaration with a different prototype than the actual declaration is an error reported by Perl, but not if the forward declaration is missing the prototype and the declaration has one - bizarre.


Perl's payment curve coincides with its learning curve.

Replies are listed 'Best First'.
Re^6: Read all the file path having text document
by shmem (Chancellor) on Nov 30, 2008 at 01:54 UTC
    ... - bizarre.

    Not at all. It's like the empty string matching any string. Once you've declared a prototype, there can be a mismatch, but not before.

      I don't understand. How is a forward declaration not a declaration?

      In both cases there is a mismatch between the forward declaration and the actual declaration. Not raising a warning in the case of a blank prototype in the forward declaration with a non-blank prototype in the actual declaration seems bizarre.


      Perl's payment curve coincides with its learning curve.

        I think not having a prototype in the forward declaration is kinda like saying "I don't care, everything is fine", so when someone comes along later and declares a specfic prototype, then this is, well, fine.  OTOH, if you say "I want the subroutine be called like this", and someone else later wants to have it some other way, you have a tiff...

        Makes sense to me.

        Well, a declaration is just a declaration - not a definition. If you add prototypes to the declaration, the declaration *is* a definition wrt the prototype part, although the subroutine body (i.e. the content of the coderef in the CODE typeglob slot) still isn't set up for lack of code to be compiled. That would be done later, in the definition. Prototypes set up earlier (via declaration) have to match, then.