DIP23 draft: Fixing properties redux
FG
home at fgda.pl
Sun Feb 3 08:14:44 PST 2013
On 2013-02-03 16:35, TommiT wrote:
> What happens here?
>
> struct S
> {
> int _n;
>
> @property ref int prop()
> {
> return _n;
> }
> }
>
> @property void prop(ref S s, int n)
> {
> s._n = 42;
> }
>
> void main()
> {
> S s;
> s.prop = 10;
> }
This is an interesting problem.
1) I think setters should outrank getters when there's an assignment.
2) Also actual methods outrank UFCS free functions with same arguments.
It's a question which rule has higher precedence.
I think no.2 does and then _n becomes 10.
More information about the Digitalmars-d
mailing list