rust-like impl / trait ergonomics? #1427
Replies: 3 comments
-
|
Two points that would worry me from a maintenance/onboarding perspective:
It seems like a nice idea. In larger projects the use of this feature has to be probably very restricted in order to make it maintainable. Just my 2 cents. |
Beta Was this translation helpful? Give feedback.
-
|
Is the point that there may be cases where it is better that you don't have to be aware of every Maybe adding impl / trait ergonomics has less value for cppfront given that cppfront has unified function call syntax where you can call |
Beta Was this translation helpful? Give feedback.
-
|
Agreeing with what @ktegan said, universal function call syntax and C++'s duck typing already solve the problems that impl would be solving. C++ concepts define a required interface for supplied types, and if the type you're passing doesn't fit that interface, you can write a free function that will be used by that interface with UFCS. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm not particularly a fan or even a user of Rust, but separating data, interface, and members via impl appears quite pleasing. I'd suspect that similar functionality could be achieved with metaclasses and reflection, but cpp2 also provides an opportunity for exploring this in a more macro-like sense: simply merging the pieces together as needed at transpilation time.
I'm making this discussion less of a suggestion and more just because I'm interested to hear any opinions or prior-art on this.
Beta Was this translation helpful? Give feedback.
All reactions