All this is in the same paragraph of oreilly Programming perl page 100 -
pub in 1991. I guess it is kinda old. Anyway, it actually says "...more
efficient..."

But I'm still sticking with showarg(); style too.

-rkl

>> But Orielly says showargs() is slower than showargs
>
> That's a good point, and something I didn't know.
>
> ...I'm not sure if it will make me change my ways though.
>
> Do you know where you read that?  I'm not sure why it would be slower, I
> would think that this would be optimized when the code is compiled to be
> the
> same speed.
>
> Rob
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Thursday, October 02, 2003 6:15 PM
> To: Hanson, Rob
> Cc: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
> Subject: RE: explicit vs implicit syntax
>
>
> I agree it looks like the best standardized candidate for use.
> But Orielly says showargs() is slower than showargs when not passing
> arguments. It's just a minor point but its something I read.
>
> In any case, I'm used to the showarg() style.
>
> thanks,
> -rkl
>
>>> showargs();
>>
>> I like this one.  It's the "usual" way to program.  In most languages
>> the
>> parens are required, so it's just easier to stick with one habit.
>
>
>> My preference...
>>
>>> &showargs();
>>
>> Ick.  I use this one when it is required (references and overriding
>> prototypes), otherwise it isn't what I mean.  If I mean to just execute
>> the
>> method, then I don't use it.
>>
>>> showargs;
>>
>> Yuk.  It saves a few keystrokes, but I tend to avoid it.
>>
>>> showargs();
>>
>> I like this one.  It's the "usual" way to program.  In most languages
>> the
>> parens are required, so it's just easier to stick with one habit.
>>
>> Rob
>>
>>
>> -----Original Message-----
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> Sent: Thursday, October 02, 2003 5:43 PM
>> To: Thomas Bätzler
>> Cc: '[EMAIL PROTECTED]'; Tim Johnson; [EMAIL PROTECTED]
>> Subject: RE: explicit vs implicit syntax
>>
>>
>> Thanks I understand what you're saying.
>>
>> If I could ask, which one of these would you use?
>>
>>> &showargs;  #NOT this is the tricky
>>
>>> &showargs();
>>> showargs;
>>> showargs();
>>
>> thanks,
>> -rkl
>>
>>> [EMAIL PROTECTED] asked:
>>>> Here's an excerpt about the & from orielly and what the heck
>>>> does it means:
>>>>
>>>> "...If a subroutine is called using the & form, the argument list is
>>>> optional. if ommitted, no @_ array is setup for the routine;
>>>> the @_ array at the time of the call is visible to subroutine
>>>> instead."
>>>
>>> If in doubt, run a test ;-)
>>>
>>> #!/usr/bin/perl -w
>>>
>>> use strict;
>>>
>>> sub showargs {
>>>   print "arguments are: " . join(', ', @_) . "\n";
>>> }
>>>
>>> sub test {
>>>   print "Arguments for test() are: " . join(', ', @_) . "\n";
>>>   print "Calling &showargs - ";
>>>   &showargs;
>>>   print "Calling &showargs() - ";
>>>   &showargs();
>>>   print "Calling showargs - ";
>>>   showargs;
>>>   print "Calling showargs() - ";
>>>   showargs();
>>> }
>>>
>>> test qw(foo baz bar);
>>> __END__
>>>
>>>> So, is there a better or worse? both ways works for me. I just started
>>>> going back and putting the & onto the sub ;) I don't like it
>>>> the & but I thought that you need it.
>>>
>>> See for yourself - there's only one use for the ampersand,
>>> and it's obscure. My advice would be to avoid using it even
>>> in the one situation where it would make sense - when passing
>>> @_ as an argument to your function. Sure, it is idiomatic Perl
>>> at its best, but it also makes a program harder to read and
>>> understand.
>>>
>>> In other words - save it for Perl Golf ;-)
>>>
>>> HTH,
>>> Thomas
>>>
>>> PS: Perl Golf - writing code with as little (key-)strokes as
>>> possible.
>>>
>>
>>
>> --
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to