www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1600] New: Functions taking only one array cannot be called with property syntax

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1600

           Summary: Functions taking only one array cannot be called with
                    property syntax
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: andrei metalanguage.com


Consider:

void test(int[]) {}
void main()
{
  int[] a;
  test(a);  // fine
  a.test(); // fine
  a.test;   // error!
}

This irregularity should be fixed. One important reason for using the property
syntax is terseness.


-- 
Oct 19 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1600


wbaxter gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wbaxter gmail.com





It's especially bad since built-in properties have the opposite restriction.

{
   int[] a;
   a.sort(); // error!
   a.sort; // fine
}

Personally I think the () variety should be allowed for the built-in properties
also.


-- 
Oct 31 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1600


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
           Keywords|                            |spec





I personally think the () should be required in both cases.  AISI a property
can be used in four ways:
- as an lvalue
- as an rvalue
- explicitly calling it with ( )
- taking the address of the getter/setter function

Using it by itself as an ExpressionStatement is none of these.

But it certainly seems wrong that an array property can't even be used as an
rvalue:
----------
int test(int[]) { return 0; }
void main()
{
    int[] a;
    int b;

    b = test(a);  // fine
    b = a.test(); // fine
    b = a.test;   // error!
}
----------
bz1600a.d(9): Error: no property 'test' for type 'int[]'
----------
(DMD 1.023, Windows)


-- 
Nov 08 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1600


Rob Jacques <sandford jhu.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sandford jhu.edu





This works in D2.031:

void foo(int[] x) {}

int main(char[][] args)
{

    auto x = new int[5];
    x.foo;

    return 0;
}

So maybe this should be closed?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 03 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1600


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





22:20:03 PDT ---
Seems to be fixed as of 2.031.

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