www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12172] New: Refused sum(transversal)

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

           Summary: Refused sum(transversal)
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2014-02-15 02:01:19 PST ---
import std.algorithm: reduce, sum;
import std.range: transversal;
alias mySum = reduce!q{a + b};
void main() {
    const data = [[1, 2], [10, 20]];
    mySum(0, data.transversal(0)); // OK
    sum(0, data.transversal(0));   // Error
}


dmd 2.065beta3 gives:

test.d(7,8): Error: template std.algorithm.sum cannot deduce function from
argument types !()(int, Transversal!(const(int[])[],
cast(TransverseOptions)0)), candidates are:
...\dmd2\src\phobos\std\algorithm.d(1070,6):        std.algorithm.sum(R)(R r)
if (isInputRange!R && !isFloatingPoint!(ElementType!R) && !isInfinite!R)
...\dmd2\src\phobos\std\algorithm.d(1115,6):        std.algorithm.sum(R)(R r)
if (hasSlicing!R && hasLength!R && isFloatingPoint!(ElementType!R))
...\dmd2\src\phobos\std\algorithm.d(1145,6):        std.algorithm.sum(R)(R r)
if (isInputRange!R && !(hasSlicing!R && hasLength!R) &&
isFloatingPoint!(ElementType!R) && !isInfinite!R)

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 15 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12172


Peter Alexander <peter.alexander.au gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |peter.alexander.au gmail.co
                   |                            |m


--- Comment #1 from Peter Alexander <peter.alexander.au gmail.com> 2014-02-22
11:09:21 PST ---
Sum doesn't allow for a seed like reduce. Is this meant to be an enhancement
request, or just a mistake?

FWIW: sum(data.transversal(0)) works fine.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 22 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12172


bearophile_hugs eml.cc changed:

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


--- Comment #2 from bearophile_hugs eml.cc 2014-02-23 13:01:05 PST ---
(In reply to comment #1)
 Sum doesn't allow for a seed like reduce. Is this meant to be an enhancement
 request, or just a mistake?

Probably it's just a mistake, sorry. Closed. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 23 2014