Why specify parameters' default values?

Asked by Paul Melis

Say you have a function

int f(int a, int b=3)

Then pybindgen allows you to write

module.add_function('f', retval('int'), [Parameter.new('int', 'a'), Parameter.new('int', 'b', default_value='3')])

Why would you want to specify what the default value of parameter 'b' is? Why not simply have a boolean flag that says "this parameter has a default value"? Is it because this saves wrapper code, as it doesn't have to check with how many arguments a function is called from Python in order to pick the correct invocation?

Question information

Language:
English Edit question
Status:
Answered
For:
PyBindGen Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Gustavo Carneiro (gjc) said :
#1

Yes. It would be too difficult/complicated to generate code without it, and the wrapper would be larger.

Can you help with this problem?

Provide an answer of your own, or ask Paul Melis for more information if necessary.

To post a message you must log in.