[% setvar title C algorithm to be selectable at compile time %]

This file is part of the Perl 6 Archive

Note: these documents may be out of date. Do not use as reference!

To see what is currently happening visit http://www.perl6.org/


sort algorithm to be selectable at compile time


  Maintainer: Simon Cozens <simon@brecon.co.uk>
  Date: 25 Sep 2000
  Mailing List: perl6-internals@perl.org
  Number: 304
  Version: 1
  Status: Developing


Quicksort and mergesort both have their uses. Let the user choose which Perl uses.


While this RFC is ostensibly to allow the user to say something like this:

        use sort 'quick';
        @array2 = sort @array;
    use sort 'merge';

the real benefit comes when the code is being compiled into a standalone executable; given sufficient magic, the compiler can analyze the expected data flow and guess what the most suitable sort algorithm should be for each instance of sort.


Provide multiple sort algorithms, and have a pragma select which Perl uses; when a program is being compiled, analyze the data and heuristically select the better algorithm if possible.