Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any chance that the next version of C++ will have Microsoft's property extension? [closed]

Tags:

c++

http://msdn.microsoft.com/en-us/library/es7h5kch.aspx

This feature looks pretty sweet. This would be great because you wouldn't need getters any more. You could make member variables public; later, if you change your mind, you can turn them into property.

Is this something that the standard committee has considered? Is this something they would likely accept or reject? Does this already exist and I just don't know about it yet?

like image 654
allyourcode Avatar asked Aug 28 '13 18:08

allyourcode


People also ask

What happens when Microsoft support ends?

Your PC will continue to start and run, but you will no longer receive software updates, including security updates, from Microsoft. For full details about the support policy, see the Microsoft Support Lifecycle Policy FAQ.

Is 2025 the end of Windows?

Though Microsoft released the new Windows 11 2022 Update to consumers today, there's no obligation to upgrade. Microsoft will continue to support Windows 10 through October 2025, company executives said.

What is Microsoft extended end date?

Extended Support typically lasts about 5 years after the end of Mainstream Support. During Extended Support, Microsoft continues to provide security and reliability updates, and bug fixes, but non-security updates are not provided without a paid support agreement.


2 Answers

Since this is already possible in standard-compliant C++ using a library-only approach (proxy objects), it's unlikely to see language changes and new keywords. Unlike lambdas (for instance), the possible syntactic sugar here isn't all that sweet (doesn't change the level of abstraction much).

BTW, changing fields (wrapperless member variables) into properties is always a breaking change, because you can form pointers and references to fields and read/write them directly. With a property, you'd need a wrapper in order to ensure that the getters and setters are used.

The reason for the Microsoft extension is that it doesn't simply provide properties (interception of read and write to getter and setter functions) in C++ code. It generates .NET metadata or WinRT metadata (in C++/CLI and C++/CX, respectively) which is used by reflection. Standard C++ doesn't have reflection or metadata.

Also note that C++ developers tend not to use the proxy object pattern very much, which indicates to the committee that there isn't much demand for a "cleaner" syntactic sugar, either.

like image 138
Ben Voigt Avatar answered Oct 10 '22 20:10

Ben Voigt


This is old. Borland added it first, back in 90s, with C++ Builder if I'm not mistaken. Microsoft followed suit, they were highly competitive back then. COM Automation was a pretty major motivator.

Given that this had three C++ language versions to stew, along with the controversy around it, the odds that this will be considered for a future revision are about zilch.

Properties have their use but they cause considerable implementation difficulties. Passing a property by reference for example is a very difficult problem to solve. The callee would need to know that an accessor needs to be called, instead of just dereferencing a pointer, and would need to know whether a getter or setter even exists. The only practical solution is to just forbid it, not exactly attractive in C++. Additional problems add up when you start to support default properties, very hard to pass up, introducing syntax ambiguity.

like image 21
Hans Passant Avatar answered Oct 10 '22 18:10

Hans Passant