3 ms·
I don't see this making it into the standard. 1. Interface = abstract class, already present. 2. Reflection, rtti is sparsely used because c++ is primarily us
by quickben 9y ago
I don't see this making it into the standard.
1. Interface = abstract class, already present.
2. Reflection, rtti is sparsely used because c++ is primarily used for speed and large teams.
3. Reserved words prefixed by $, etc. Well, outside of a preprocessor directives, that will be a first , if it ever happens.
By the look of the thing, the author wants c++ to be more like c#. But c++ isn't restricting on patterns, we create them. Unlike c# there is no language defined way for dependency injection, interfaces etc. Well we can argue that, but c++ is more flexible on pattern creation, and this proposal wants to put two patterns inside the standard. I just don't see it happening.
- kmill 9y ago1. It's about abstracting what "classes" are, since the built-in "class" metaclass is trying to be one-size-fits-all. Yes, an interface is an abstract class, and if you could do things like make your own "interface" metaclass, then you can "create more patterns," in your words. 2. This is compile-time reflection, which is how a metaclass generates code, so there shouldn't be much of a run-time speed consideration. I think the comparison with C# isn't quite right; if anything, the author wants C++ to be more like Lisp, Smalltalk, or even Python, which all have at least some semblance of a meta-object protocol (and code-writing code, in the case of Lisp).
- quickben 9y ago1. Classes itself can be improved, but at this point, will they date breaking compatibility? Maybe from that perspective this will be given a shot. 2. More code at compile time would work. Pythinizing may work. Lisp is quite different.
- moomin 9y agoIndeed. I think this is one of the best things about the proposal: it offers a way out of the current hardcoded behaviours. At the moment we barely even think about whether or not they're correct, because they're obviously too hard to opt out of.
- aoloe 9y agoindeed, there is one thing i don't understand: why $class and not metaclass...
- quickben 9y agoIt can be $meta-class::class :) Keep in mind simple=elegant is not in everybody's eyes.
- deleted 9y ago[deleted]
- stinos 9y ago1. $interface is just one example. Look at the $value example and defining an operator == which automatically works for all members: that does not yet exist 2. Some (or all? not sure..) of the reflection capabilities this brings are compile-time so no runtime speed penalty 3. There's a first for everything :] That being said, I'm also not sure it if will make it to the standard but for different reasons; mainly that it's a pretty huge change and will make C++ even more mature/difficult/one language to rule them all/easier to rant on/...