David Le Blanc wrote: > > > From: Michael C. Davis [mailto:[EMAIL PROTECTED] > > Sent: Friday, 27 February 2004 11:55 PM > > To: [EMAIL PROTECTED] > > Subject: subroutine call weirdness > > > > Hi list, > > > > I just ran across some unexpected results in passing arguments to > > user-defined subroutines. Could someone who has been around > > Perl a while > > longer check this and make sure I'm seeing this right? > > > > I've got some code that implements a constant as a subroutine > > call (to keep > > the constant from being modified). When I use that subroutine in an > > arithmetic expression, it is consuming everything to the > > right of it as its > > argument list. > > This is correct. That is why Larry said, "Let there be Prototypes". > > Now remember, a perl 'prototype' is not a prototype in the regular > sense, but a method to override perl's natural greedy argument list > collection, and a method to create functions which emulate perl's > builtins (ie, provide hints to the expected calling context).
But prototyping turns a subroutine into an operator: a very different thing. I would be very wary of creating new built-ins unless they were very carefully written, guaranteed to be bug-free, and parcelled away and documented as such. A simple constant (especially a run-time evaluated one, as the OP had) is much better declared using the 'constant' pragma. All IMO. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>