[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

RE: [FWP] aCertainName.pm



> From: Ronald J Kimball [mailto:rjk@linguist.dartmouth.edu]
> Sent: Wednesday, November 10, 1999 13:44
> To: Larry Rosler
> Cc: 'Steve Lane'; fwp@technofile.org
> Subject: Re: [FWP] aCertainName.pm
>
> On Wed, Nov 10, 1999 at 01:23:40PM -0800, Larry Rosler wrote:
> > > From: Steve Lane [mailto:sml@zfx.com]
> > >
> > > wouldn't the functions that take either a scalar
> > > or list argument be easier to write using:
> > >
> > >   @_ = ($_) unless @_;
> > >
> > > instead?
> >
> > Easier, perhaps.  Correct, no!
> >
> > We're trying to reproduce the semantics of abs(), which say nothing
> > about clobbering @_ if there is not argument.
>
> If there is no argument, then there is nothing in @_ to clobber.
>
> Correct, yes!

Correct, no!

my foo {
   my $x = abs; # Sets @_ to $_.
   &bar; # Expects the same arguments as foo(), namely none, but now
gets $_.
}

@_ has been 'clobbered' by abs()!

--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com



==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe