December 01, 2004
Are properties supposed to be evaluated differently based on how they are called?

# class C
# {
#     C c = new C();
#     C lock() { return c; }
# }
#
# void main()
# {
#     C c = new C();
#     synchronized( c.lock() ) {}
#     synchronized( c.lock ) {}
# }

D:\code\d>dmd test
test.d(11): can only synchronize on class objects, not 'C ()'


December 01, 2004
"Sean Kelly" <sean@f4.ca> escribió en el mensaje
news:coksfq$2rrh$1@digitaldaemon.com...
| Are properties supposed to be evaluated differently based on how they are
| called?
|
| # class C
| # {
| #     C c = new C();
| #     C lock() { return c; }
| # }
| #
| # void main()
| # {
| #     C c = new C();
| #     synchronized( c.lock() ) {}
| #     synchronized( c.lock ) {}
| # }
|
| D:\code\d>dmd test
| test.d(11): can only synchronize on class objects, not 'C ()'
|
|

This is a kinda old defect with D properties. I've been bit by this many times and that's why I agree properties syntax should change. But since it's been talked too many times already, I don't think such change will happen.

-----------------------
Carlos Santander Bernal