http://d.puremagic.com/issues/show_bug.cgi?id=9062

           Summary: AddrExp should distinguish the existence of property
                    resolution.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: k.hara...@gmail.com


--- Comment #0 from Kenji Hara <k.hara...@gmail.com> 2012-11-22 19:31:04 PST ---
In this case, p is an address of g, or function pointer to foo?

  int g;
  @property ref int foo() { return g; }
  auto p = &foo;

Until now, &foo always returns function pointer. If we want to get &g, we could
write as like:

  auto p = &foo();  // call foo first, then get an address of return value

But, if @property would be implemented more strictly, the syntax foo() will be
disallowed. In other words, getting &g from &foo will be impossible. It is a
serious flaw.

----

To resolve the problem, I'd like to propose a small special syntax: &(foo).
If AddrExp has a parenthesized expression, a property function in the operand
will be resolved to property call.

  pragma(msg, typeof( & foo  ));  // will print "int function() @property ref"
  pragma(msg, typeof( &(foo) ));  // will print "int*"

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to