zsdc wrote:

> R. Joseph Newton wrote:
> > "Charles K. Clarkson" wrote:
> >
> >>   Here begins my problems with prototypes. Let's try
> >>this sample script:
> >
> >>sub generate_report_html([EMAIL PROTECTED]@);
> >
> > which could also be written:
> > sub generate_report_html($$$);
> >
> > with much greater clarity.
>
> This is not the same. A '$' in the subroutine prototype means a scalar,
> any scalar, while '\@' means that the argument must start with '@' and
> it will be passed to the subroutine as an array reference.
>
> See perldoc perlsub.
> --
> ZSDC

Got it.  I'll still stick with what I said, though.  This "feature" offered by
Perl prototypes strikes me as primarily a seed of confusion.  Particularly in
the context of a beginners list, it obscures the underlying issue concerning
subroutine arguments--that subroutines take only a list of scalars as their
arguments.  When we have so many beginners tripping themselves up by trying to
avoid the use of explicit references, this syntactic "convenience" only prolongs
the pain and confusion.

I must say, this is clearing up a point of cusiosity for me, as to how functions
like
chomp @lines;
can work on the original structure as called.  Although it's made me raise my
eyebrows off and on, I've never pursued it.  The Perl core can take take of
itself.  The functions are well-documented, so you can follow the calling
sequence shown in the docs, and they work.  Nevertheless, there is a real
ambiguity about the arguments offered to a function making use of this feature.

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.

Joseph



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to