[Issue 3395] New: Ambiguous array operations

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 14 01:15:49 PDT 2009


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

           Summary: Ambiguous array operations
           Product: D
           Version: 2.032
          Platform: All
               URL: http://www.digitalmars.com/d/2.0/arrays.html
        OS/Version: All
            Status: NEW
          Keywords: spec
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: dfj1esp02 at sneakemail.com


--- Comment #0 from Sobirari Muhomori <dfj1esp02 at sneakemail.com> 2009-10-14 01:15:48 PDT ---
These expressions are ambiguous:
---
a[].max(n);
a[1..4].max(n);
---
Does it mean calling the function on the slice or on each item in the slice?

Possible solution is to change the meaning of empty square brackets from full
slice to only a hint for array operation so that a[].max(n) is an array
operation and a[1..4].max(n) is max(a[1..4],n).
This also gives possibility to extend array operation to whole statement even
if it's not an lvalue:
---
printf("%.4f, ",a[]);
becomes
foreach(v;a)printf("%.4f, ",v);
---
a[].max(n) and max(a[],n) become the same and unambiguous with other use cases.

-- 
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