|
Boost : |
Subject: Re: [boost] [property] interest in C# like properties for C++?
From: Sid Sacek (ssacek_at_[hidden])
Date: 2009-10-22 13:17:04
A property is a "published data member of an object".
And since a public property is "published", it's interface cannot and must not change.
object.x = 10;
It doesn't matter if 'object.x' is an integer or a sophisticated object impersonating an integer,
whoever or whatever generates the underlying code must not break the 'publicly published' interface.
So the worry about code not compiling in the future is actually unfounded.
-Sid Sacek
-----Original Message-----
From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On Behalf Of David Brownstein
> The only real difference that I see between assignment-style and
> function-style accessors is that if you use function-style accessors and
> later you replace an automatically generated accessor with a customized
> (manually generated) accessor, then all of the code that uses the original
> accessor continues to work (with a recompile).
>
> For example:
>
> struct MyClass
> {
> Property<int> counter;
> };
>
> void foo()
> {
> MyClass x;
>
> x.counter( 5 );
> }
>
> Now let's say that we re-define MyClass:
>
> struct MyClass
> {
> void counter( int iValue ) { counter = iValue; NotifyObserver(); }
>
> private:
> int counter;
> };
>
> The function foo() doesn't need to be changed. This is more difficult to do
> with assignment-style accessors.
>
> David
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk