www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Bug with properties?

reply Sean Kelly <sean f4.ca> writes:
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 ()'
Dec 01 2004
parent "Carlos Santander B." <csantander619 gmail.com> writes:
"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 
Dec 01 2004