Boost logo

Boost :

Subject: Re: [boost] [property] interest in C# like properties for C++?
From: Sid Sacek (ssacek_at_[hidden])
Date: 2009-10-21 13:26:55


Sorry,

Edward Diener is absolutely correct in this manner.

The C# language is very clear about what properties are, why they're part of the language, and how they're used.

Let me remind you that this topic is: "interest in C# like properties for C++?"

    x.count() is not a property usage... it is a blatant accessor function call

Think about these two lines of code:

    int x, y;
    x = y = 100;

Now, if x and y were properties instead of variables, you would be able to write code like this:

    obj.x = obj.y = 100;

Now, how would you write that line of code using accessor functions? By any standard, it would be inferior to the syntax above.

-Sid Sacek

-----Original Message-----
From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On Behalf Of Stefan Strasser
Sent: Wednesday, October 21, 2009 1:06 AM
To: boost_at_[hidden]
Subject: Re: [boost] [property] interest in C# like properties for C++?

> > > [Stefan Strasser [strasser_at_[hidden]] wrote:]
> > >
> > > x.count(5);
> > > int I = x.count();
> >
> >
> > [ Edward Diener [eldiener_at_[hidden]] wrote: ]
> >
> > I do not believe this is the right syntax for accessing properties. The
> > idea of a "property" is that one uses syntax to access it as if it were
> > a data object, while it still has the backing of a function to provide
> > constraints.
>
> [Stefan Strasser [strasser_at_[hidden]] wrote:]
>
> why? there is no widely used practice to use public data objects.
> so why would you need a property to emulate that syntax?
>
> while you might not consider accessor functions a property in the language
> construct sense, they do represent a property of the object they're a part
> of. this is widely used in the C++ standard library and boost.
> what's the rationale for another properties syntax?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk