Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Methods that take options should take hashes not refs #243

notbenh opened this Issue · 1 comment

2 participants

$thing->method(option => 42);

rather then the current goal for v2

$thing->method({option => 42});

We discussed this briefly at the PDX Hackathon. How our methods take options is a bit higgly piggly. The argument for using a normal hash is quite simple, its easier to type and remember. It also happens to jive with how named parameters work in Method::Signatures if we wind up using that.

IIRC I'd originally intended to have methods take a hash ref for two reasons. 1) Its a bit more memory efficient and 2) its easier to distinguish the options from other arguments.

1 doesn't matter for the overwhelming majority of option passing, and if we do need to pass in something large as an option the individual option can be passed in as a scalar.

2 doesn't matter for us because, with autoboxing, we pass in the data as the object. Any auxiliary stuff can come in either as an option or, if its required, as a positional in front of the options. $thing->method( $more_data, option1 => value2, option2 => value2 ); If we need to pass in more data later it must be optional, so it goes with the options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.