www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5924] New: schwartzSort of Tuple!(char)[]

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

           Summary: schwartzSort of Tuple!(char)[]
           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



D2 code:

import std.algorithm, std.typecons;
void main() {
    //Tuple!(int)[] chars; // OK
    Tuple!(char)[] chars; // Error
    schwartzSort!((c){ return c[0]; })(chars);
}


It doesn't compile with DMD 2.052:

...\dmd\src\phobos\std\algorithm.d(5911): Error: template instance
SortedRange!(Zip!(char[],Tuple!(char)[]),myLess) does not match template
declaration SortedRange(Range,alias pred = "a < b") if
(isRandomAccessRange!(Range))
...\dmd\src\phobos\std\algorithm.d(5912): Error:
SortedRange!(Zip!(char[],Tuple!(char)[]),myLess) is used as a type


You can't sort efficiently the items of an Unicode string because in general
they don't have the same length. But a dynamic array of Tuple!(char) is
composed by items 1 byte long, and generally it's not meant to be a string. So
in this case I expect schwartzSort to be able to sort it.


Current workaround:

import std.algorithm, std.typecons;
void main() {
    Tuple!(char)[] chars;
    schwartzSort!((c){ return cast(int)c[0]; })(chars);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 03 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5924


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


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




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/48c38ddd2c17fc431056e990fd8919c6d97c4d89
Issue 5924 fix

https://github.com/D-Programming-Language/phobos/commit/118d9182a908777d9776fc6aa0d704bced0a8a51


Fix Issue 5924 - schwartzSort of Tuple!(char)[]

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 24 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5924


Alex Rønne Petersen <alex lycus.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|                            |alex lycus.org
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 24 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5924


bearophile_hugs eml.cc changed:

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



Currently reverted:

https://github.com/D-Programming-Language/phobos/commit/a8f180a7c71b902b7fc92dcc31e8be8d5b7a9d1e

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 25 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5924




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/56c47cecbe277b7274931c2d925fb13db2b9302c
Issue 5924 fix

https://github.com/D-Programming-Language/phobos/commit/707a60101b41ac54af2f757beec89875fe51ac37


Fixes Issue 5924

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 25 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5924


Alex Rønne Petersen <alex lycus.org> changed:

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 25 2013