On 2013-16-09 20:34, robbyt wrote:
Henrik,

Thank you for your quick response. Sorry mine wasn't so quick- Google
ate my message, perhaps it contained too many curly braces. :)

Anyhow, adding a default argument option to lookup() would be great. But
adding the option to pass a hash with keyword arguments would be even
better!

Python solved the API UI for this quite well with **, and *.
http://docs.python.org/release/2.7.4/tutorial/controlflow.html#keyword-arguments
and
http://docs.python.org/release/2.7.4/tutorial/controlflow.html#unpacking-argument-lists

Imo, the 2nd positional argument of the lookup() function should accept
ONLY a hash. Otherwise, what would I do if I want to set a hash to BE
the default argument?

e.g.,

1st Positional argument as a hash?
Ambiguous positional argument (error!)
lookup('namespace::some_hash', {'my_key' => 'my_value'})

More explicit, better:
lookup('namespace::some_hash', { type => 'Hash', default => {'my_key' =>
'my_value'} })


Here are the possible alterantives:

arity 1: String key
arity 1: Hash options
arity 2: String key, String | Type type
arity 2: String key, Hash options
arity 3: String key, String | Type type, Object default_value

Regards
- henrik

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to