'Sour Ce' via cython-users schrieb am 13.06.21 um 17:31:
> Either way I'm bummed out again after realizing today that non-extern
> cppclasses inheriting from an extern cppclass actually loses all overloaded
> methods without any notification.
Not sure what exactly you describe here, but it sounds like something that
could be easy to fix.
Could you please open a ticket and add some example code to it? Or, even
better, implement a failing test in a PR?
> Cython did allow me to create an extern cppclass that inherits from a
> non-extern cppclass class,
Doesn't sound entirely unreasonable to me, but also not like a major use case.
> Also I've found some more caveats/strange behaviors during the past week:
> * Cppclass methods converts varname into this.varname if varname is a class
> attribute or method.
> I.e. the method "call(): a()" will call this.a() even if there is a
> function a() as long as global a is not declared. This differs from cdef
> classes and I believe python classes as well which defaults to local >
> global unless the self or this prefix is used explicitly, while cppclass
> methods seem to default to local > this.
Up to debate, I guess. C++ methods do not have an explicit self/this, so
they already are different from Python methods.
I think the question is mostly: what is a C++ method more likely to do? Use
other C++ attributes and methods? Or use surrounding code? If the answer is
strongly one of the two, then that's a reason to follow C++ or Python
semantics.
That doesn't mean that I don't see the argument of consistency – it's an
important one. I'm rather trying to find out if the behaviour is worth
changing at this point.
> * Extern from is the only clause I'm aware of that silently drops duplicate
> definitions. Perhaps understandable, but a little unexpected and confusing
> when you're not aware (lead me to spend days reworking my class into a
> cppclass only to realize today that my overloaded methods had been silently
> dropped).
Sounds like a bug to me. Declarations should be either clear and correct,
or get rejected. Also worth a ticket.
> * Cppclass construction with anything pythonic causes segfault.
> I.e. cppclass test: test(): ['a', 'b', 'c', 1, 2, 3] # segfault
> * Dict's can be converted to maps... but kind of sporadically.
> E.g. cdef void test(map[unsigned int, unsigned int] m): pass
> test({1: 1}) # Cannot interpret dict as type 'map[unsigned int, unsigned
> int]'
> d = {1: 1}
> test(d) # Works!
Same, please create bug tickets for these.
Thanks for fighting your way through this. As mentioned before, C++ class
support wasn't meant to replace C++ as such, rather to close a gap when
users need to define them. There is definitely room for improvements.
Stefan