Skip to content
New issue

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

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Keyword arguments to calls #6

Open
arnsholt opened this issue Nov 27, 2014 · 2 comments
Open

Keyword arguments to calls #6

arnsholt opened this issue Nov 27, 2014 · 2 comments

Comments

@arnsholt
Copy link
Owner

Python doesn't really have keyword arguments (except when it does), only positionals. Thus, a call like foo(a=1) actually passes the value of argument a in its positional slot. The only case where keyword args have an independent existence is when a function has a **excess parameter to contain names not already defined in the parameter list.

Thus, we need some kind of binder process, either converting nameds to positionals or positionals nameds. Of course, this has to interact properly with default values and the like.

@arnsholt
Copy link
Owner Author

The solution to this might be a custom HOW for function objects. The call handler can then stuff the right things into the right places, and the object can also carry around the default values to parameters.

@arnsholt
Copy link
Owner Author

arnsholt commented Dec 3, 2014

One potential way to do this:

A function object is supposed to have a member defaults containing the default values. A call handler can then nqp::clone that to get the default values. Next, populate actually passed values into the call arguments (there's no standard member with a name -> position mapping, but the inspect standard module needs it anyways). Once everything is set up, nqp::call(_args, *_excess_kw) or something along those lines.

There are still some things (mostly related to the semi-predicate problem, I think) to get checking of calls exactly right, though. But this should get us some things.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant