Usages of defaultParameters and parameterNames

David Nolden zwabel at
Sun Feb 24 22:24:20 UTC 2008

On Sunday 24 February 2008 14:25:18 Andreas Pakulat wrote:
> On 24.02.08 13:58:42, Andreas Pakulat wrote:
> > Hi,
> >
> > how are the above functions from AbstractFunctionDeclaration used in
> > C++? According to the docs defaultParameters may be a problem for
> > python, because a python function can have:
> >
> > def foo(bar=1,*foo,**baz)
> >
> > i.e. the last defaultParameter is not necessarily the last paramter. I'm
> > thinking we might need to introduce a proper list of structures there,
> > something very simple with just a name an optional a value.

The problem is memory-usage, because that list would be created for every 
single function out there. What about just filling up the not given 
default-parameters with QString()?

> Actually, I've got even worse problems. I can't really fill these except
> for the simplest case of a parameter name. But in python I can also have
> a list of parameter names (like def foo( (bar,baz,foo) ) as 1 argument.
> Where of course each name is a separate variable inside the function,
> but you can only call that function either as
> foo() or foo([1,5,2]) (or anything else in the list). And I can access
> the 3 elements with the names.
> So I'm thinking about simply not filling these, if they're not that
> important.
I think currently the parameter-names are used while completion to show the 
name. However it should also be possible to extract them from the 
function-context, so maybe we could even remove that whole thing.

> Also something similar exists for the default values, that can be any
> arbitrary expression.

In C++ the default-values are evaluated as expressions on demand, and are also 
shown in the argument-hints, so they are quite useful. Probably in python 
they should be useful too.

However, are single default-parameters even possible for that "(bar, baz, 
foo)" thing? Doesn't python expect the given parameter to be a 3-tuple, so a 
default-parameter should more look like def foo( (bar,baz,foo) = [0,1,2] ). 
So the problems would be those *foo and **baz things, but I would also count 
those as single parameters, so it should be possible to fill the 

Greetings, DAvid

More information about the KDevelop-devel mailing list