D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6970 - Pseudo Members
Summary: Pseudo Members
Status: RESOLVED DUPLICATE of issue 3382
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-18 04:07 UTC by Matthias Frei
Modified: 2011-11-18 07:33 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Matthias Frei 2011-11-18 04:07:45 UTC
According to TDPL, 5.9.1 "Pseudo Members and the @property Attribute", D allows pseudo-member notation:
"if a.fun(b,c,d) is seen but fun is not a member of a's type, D rewrites that as fun(a,b,c,d) and tries that as well."

Apparantly this is only true for arrays, and even for arrays it does not work in some cases:

void gun(ref int[]) { }
void sun(ref int[], int v) { }

int[] global;
ref int[] fun() { return global; }
@property ref int[] funProp() { return global; }

void main() {
    gun(global);       // works
    sun(global, 0);    // works
    global.gun;        // works (but shouldn't ?)
    global.gun();      // works
    global.sun(0);     // works
    fun().gun;          // works (but shouldn't ?)
    fun().gun();        // works
    fun().sun(0);       // works
    funProp.gun;        // works (but shouldn't ?)
    funProp.gun();      // does not work but should
    funProp.sun(0);     // does not work but should
}
Comment 1 Nick Sabalausky 2011-11-18 07:33:09 UTC
Duplicate of issue 3382, issue 2883, and issue 662

*** This issue has been marked as a duplicate of issue 3382 ***