Thread overview | |||||
---|---|---|---|---|---|
|
March 11, 2011 [Issue 5729] New: taking the address of a @property doesn't work | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5729 Summary: taking the address of a @property doesn't work Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: mrmocool@gmx.de --- Comment #0 from Trass3r <mrmocool@gmx.de> 2011-03-11 08:50:19 PST --- class A { private int blub = 5; @property ref int bla() {return blub;} } void main() { A a = new A(); int* b = &a.bla; } property.d(11): Error: cannot implicitly convert expression (&a.bla) of type int delegate() @property ref to int* This only works by adding parentheses: &a.bla() Shouldn't it work as expected without those for @property methods? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 01, 2011 [Issue 5729] taking the address of a @property doesn't work | ||||
---|---|---|---|---|
| ||||
Posted in reply to Trass3r | http://d.puremagic.com/issues/show_bug.cgi?id=5729 Harry Vennik <htvennik@zonnet.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |htvennik@zonnet.nl --- Comment #1 from Harry Vennik <htvennik@zonnet.nl> 2011-04-01 09:32:40 PDT --- The point is that you are getting the address of the property function, not the address of the ref return value. Adding the () changes this, because the () is evaluated before &. So the real problem is a syntax ambiguity. It depends on the context how the reference to the property is evaluated. Try this: typeof(a.bla) // returns int typeof(&a.bla) // returns int delegate() @property ref -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 01, 2011 [Issue 5729] taking the address of a @property doesn't work | ||||
---|---|---|---|---|
| ||||
Posted in reply to Trass3r | http://d.puremagic.com/issues/show_bug.cgi?id=5729 --- Comment #2 from Harry Vennik <htvennik@zonnet.nl> 2011-04-01 09:42:57 PDT --- Really amazing: typeof(A.bla) // int typeof(&A.bla) // int function() @property ref typeof(*&A.bla) // int (The difference with the previous post is that I am referring to class A instead of its instance a.) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation