|
Boost : |
Subject: Re: [boost] [property] interest in C# like properties for C++?
From: Stefan Strasser (strasser_at_[hidden])
Date: 2009-10-22 11:47:13
Am Thursday 22 October 2009 16:10:59 schrieb Stewart, Robert:
> David Brownstein wrote:
> > I also
> > share your belief that using function-style accessors rather
> > than assignment is preferable.
>
> Why? What does that syntax offer you that makes it better? I understand
> Gennadiy's notion of searching for ".value" allowing him to find cases in
> which he assigns to a "property," though I fail to understand why such a
> search is important. I don't understand how parentheses help anything.
>
> In your code, you seem to support both syntaxes:
>
> std::string strName = Z.Name();
> int iCount = Z.Count;
> Z.Count(3);
> Z.Count = 6;
>
> I see nothing gained by using parentheses.
see my previous mails for arguments in favor of accessor functions, but if
people don't agree with that, at the very least both syntaxes should be
supported, because interfaces using properties and interfaces using accessors
can overlap.
take for example a GUI library that uses your proposed properties. a
GUI "list" widget would probably make its list elements available through the
interface of a STL container, so it must support size().
but you'd probably also want a property named "size", if that is how the rest
of the GUI library is designed.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk