Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Style - how to give class method call as parameter

by dsheroh (Prior)
on Jun 26, 2012 at 14:31 UTC ( #978438=note: print w/replies, xml ) Need Help??


in reply to Style - how to give class method call as parameter

Well, I don't want to use named parameters for such a simple task.
Why not? It's not like they're difficult to implement/use in Perl. You could even use a mix of positional (required) parameters and named (optional) parameters:
my $success = $deployer->extend_order_lease( $order, $end_date, timeou +t => $timeout );
There's also the option of making it an optional positional parameter, but that tends to be a bad idea, due to things getting messy if you add more optional parameters down the road.
my $success = $deployer->extend_order_lease( $order, $end_date[, $time +out] );

Replies are listed 'Best First'.
Re^2: Style - how to give class method call as parameter
by strat (Canon) on Jun 26, 2012 at 18:14 UTC

    Hello dsheroh,

    I don't want to use named parameters for this because it is just a simple call. I usually don't like mixed parameters, and with names for everything, I need to write something like:

    my $success = $self->do_method_with_timeout( timeout => $timeout, object_or_class => $deployer method => 'extend_order_lease', args => [ $order, $end_date ], );

    In my eyes, too much code for a simple thing

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://978438]
help
Chatterbox?
[choroba]: Yes, sometimes missing ; after the use clause just interprets the next line somehow and passes the result to the used module which could happily ignore it. Been there, seen that.
[Discipulus]: luckly the program was 20 lines!

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2017-02-28 08:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (398 votes). Check out past polls.