Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

cppyy passing arguments by name to C++ binding #16406

Open
will-cern opened this issue Sep 11, 2024 · 1 comment
Open

cppyy passing arguments by name to C++ binding #16406

will-cern opened this issue Sep 11, 2024 · 1 comment

Comments

@will-cern
Copy link
Contributor

Feature description

Is it possible to support passing arguments by name to a C++ method in cppyy, including passing out of order and not passing all arguments if some are defaulted?

Here is an example:

import ROOT

ROOT.gInterpreter.ProcessLine("""
class MyClass {
public:
    class MyObj {
    public:
        MyObj(const char* in) : s(in) { }
        TString s;
    };
    void MyMethod(const MyObj& x="hello", bool opt=false, bool opt2=true) {
      std::cout << x.s << " " << opt << " " << opt2 << std::endl;
    }

};
""")

ROOT.MyClass().MyMethod(opt2=False,x="hi") # I'd like this to output "hi 0 0"

At the moment this produces:

File cppyy_default_compiler:1, in <module>

NameError: name 'false' is not defined

Thanks!

Alternatives considered

No response

Additional context

No response

@guitargeek
Copy link
Contributor

I thought this was already working 🙂 But okay, if it's not working I agree we should support this 👍 This will help a lot in making C++ interfaces feel more pythonic without writing explicit pythonization wrappers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants