digitalmars.D.learn - Do property attributes not allow postincrement operators
- Jamie (18/18) Apr 13 2019 Do @property attributes not allow postincrement operators?
- Mike Franklin (12/30) Apr 13 2019 It's a long standing issue (going on 7 years old)
- Jamie (3/11) Apr 13 2019 Thanks Mike -- appears I didn't do a thorough enough search for
Do property attributes not allow postincrement operators?
import std.stdio;
struct Foo {
property bar() { return 10; }
property bar(int x) { writeln(x); }
}
void main()
{
Foo foo;
writeln(foo.bar); // actually calls foo.bar();
foo.bar = 10; // calls foo.bar(10);
// following doesn't work
foo.bar++; // would expect this to call foo.bar(foo.bar() +
1);
// have to use:
foo.bar = foo.bar + 1;
writeln(foo.bar);
}
Apr 13 2019
On Sunday, 14 April 2019 at 01:54:39 UTC, Jamie wrote:
Do property attributes not allow postincrement operators?
import std.stdio;
struct Foo {
property bar() { return 10; }
property bar(int x) { writeln(x); }
}
void main()
{
Foo foo;
writeln(foo.bar); // actually calls foo.bar();
foo.bar = 10; // calls foo.bar(10);
// following doesn't work
foo.bar++; // would expect this to call foo.bar(foo.bar() +
1);
// have to use:
foo.bar = foo.bar + 1;
writeln(foo.bar);
}
It's a long standing issue (going on 7 years old)
https://issues.dlang.org/show_bug.cgi?id=8006
There's an implementation at
https://github.com/dlang/dmd/pull/7079
It requires a DIP, which you can find at
https://github.com/dlang/DIPs/pull/97
However, in preparing that DIP other issues were discovered with
property, so we need to create a DIP to fix those issues first.
I plan on getting to it, but there are other pressing things I'm
trying to get out of the way.
Mike
Apr 13 2019
On Sunday, 14 April 2019 at 02:11:52 UTC, Mike Franklin wrote:On Sunday, 14 April 2019 at 01:54:39 UTC, Jamie wrote:Thanks Mike -- appears I didn't do a thorough enough search for this behaviour. Looking forward to it being implemented, cheers.Do property attributes not allow postincrement operators? ...It's a long standing issue (going on 7 years old) ... I plan on getting to it, but there are other pressing things I'm trying to get out of the way. Mike
Apr 13 2019








Jamie <notme gmail.com>