Re: subroutine definitions

From: Wc -Sx- Jones (sx_at_insecurity.org)
Date: 03/01/04


Date: Mon, 01 Mar 2004 03:25:50 -0500
To: 'beginners' <beginners@perl.org>

R. Joseph Newton wrote:

> I would see this in a more positive light, perhaps, if prototypes were more
> required for all functions, particularly if they offered named formal
> parameters. In those circumstances, prototypes would offer great benefits of
> clarity, since one could always refer to the signature of any function to see
> whether the argument should be taken by value or reference. The random
> application of prototypes to allow inconsistent calling syntax does not seem to
> me to add any clarity.

No, but there-in lies the true power and true nightmare that is Perl.

However, it is better to go with your training and experience and simply
write Perl code according to your own/company guidelines so that if you
need to look back (or if someone else needs to look back for you) you
will know why things were written that way in the first place.

Even Larry Wall has stated "Do I really need ten ways to do something?"

Functionality and Clarity are more important over Compactness and Speed.
  I mean what good is a piece of code to find words with "even sets"[1]
of vowels if no one else understands or can maintain it.

Perl already has a bad history of being WRITE-ONLY; lets see if we can
all make it re-usable?

-Bill-
__Sx__________________________________________
http://youve-reached-the.endoftheinternet.org/

[1] 'even' would match as it has 2 e's...



Relevant Pages

  • Re: Dynamic Typing, Defencive Programming and Prototypes (Was: Interfaces and Type Safety)
    ... your example compiles but as soon as I try doing something after this sig ... > Note that tied hashes or arrays are conceptually overloading the subscript ... Another logical way to look at it is that it's unlikely that Perl ... syntactic sault for dealing with prototypes. ...
    (comp.lang.perl.misc)
  • Re: subroutine definitions
    ... > Perl prototypes strikes me as primarily a seed of confusion. ... When we have so many beginners tripping themselves up by trying to ...
    (perl.beginners)
  • Re: prototypes - use or not?
    ... DB> Perl Best Practices, section 9.10, has a pretty clear ... DB> statement that subroutine prototypes should not be ... (It says that the disadvantages generally outweigh ... just what pbp says, don't use them unless you have a very good reason to ...
    (comp.lang.perl.misc)
  • Re: What with this open file descriptor/"Read on closed filehandle " stuff?
    ... > has a special meaning in subroutine calls, ... When speaking about prototypes, we have to acknowledge that they ... I don't see why the ampersand should ... is a violation against anything that Perl stands for. ...
    (comp.lang.perl.misc)
  • Re: subroutine definitions
    ... >> with much greater clarity. ... A '$' in the subroutine prototype means a scalar, ... > it will be passed to the subroutine as an array reference. ... Perl prototypes strikes me as primarily a seed of confusion. ...
    (perl.beginners)