properties - Why not the set/get syntax?

John C johnch_atms at hotmail.com
Sat Apr 1 05:16:40 PST 2006


"Cris" <central_p at hotmail.com> wrote in message 
news:e0lr0p$2n17$1 at digitaldaemon.com...
> How would you implement a  write only property?

Implement only the setter.

>
> So if you want ot have a read and write property you just have to add one 
> read and one write property?

Correct.

>
>> struct Foo
>> {
>>     int data() { return m_data; } // read property
>>
>>     int data(int value) { return m_data = value; } // write property
>>
>>   private:
>>     int m_data;
>> }
>
> C#'s syntax feels a little bit more clear to me. I'm reading now the link 
> you've posted before.

I agree it's a lot nicer. But many think it's too verbose. I'd be willing to 
sacrifice succinctness for clarity. 





More information about the Digitalmars-d mailing list