[Issue 9062] New: AddrExp should distinguish the existence of property resolution.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 22 19:31:09 PST 2012


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: nobody at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at 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: -------


More information about the Digitalmars-d-bugs mailing list