digitalmars.D.bugs - [Issue 3395] New: Ambiguous array operations
- d-bugmail puremagic.com Oct 14 2009
- d-bugmail puremagic.com Oct 14 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 puremagic.com ReportedBy: dfj1esp02 sneakemail.com --- Comment #0 from Sobirari Muhomori <dfj1esp02 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: -------
Oct 14 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3395 --- Comment #1 from Sobirari Muhomori <dfj1esp02 sneakemail.com> 2009-10-14 01:31:43 PDT --- This also has to do with type safety. --- a[]=b[]; --- This expression is ambiguous. What was meant? Copy items from b[] slice to a[] slice or assign b[] slice to each item in a[] slice? Ambiguity resolution: --- a[]=b[]; //copy items from b to a a[]=b; //assign b slice to each item in a slice a[]=b[0..$]; //ditto --- And types for the operation must match or an error will be issued. --- T[] a,b; a[]=b; --- Currently this is accepted, but should fail, the right side expression in this assignment must be of type T (or T[] with array op). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 14 2009








d-bugmail puremagic.com