Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Methods that take options should take hashes not refs #243

notbenh opened this Issue Mar 22, 2013 · 1 comment


None yet
2 participants

notbenh commented Mar 22, 2013

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

rather then the current goal for v2

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

schwern commented Mar 22, 2013

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