Collection classes and the Buf type for Rakudo
- Name:
-
Carl Mäsak
- Email:
-
<cmasak@gmail.com>
The aim of this project is to implement the types Set, Bag, KeyHash, KeySet, KeyBag and Buf in Rakudo Perl 6.
Rakudo is quickly taking the lead among the Perl 6 implementations as the most feature-complete and up-to-date one. I'm applying for this grant in order to fund my time to help implement a few collection types described in the Perl 6 specification.
D1. Flesh out the Perl 6 spectest suite to cover the known functionality required of the Set, Bag, KeyHash, KeySet, KeyBag and Buf types.
D2. Clear up the details missing in the Perl 6 specification about creation, modification and introspection of these types.
D3. Implement the above types in Rakudo Perl 6, to the extent possible by the then limitations imposed by the spec, Rakudo and Parrot.
Arrays and hashes are already in place in Rakudo, but there are a few core data types that haven't been implemented yet:
* KeyHash * Set and KeySet * Bag and KeyBag * Buf
All but the last are collection types, and Buf is a kind of hybrid between an unencoded Str and an Array. All of these types suffer from slight underspecification and a paucity of tests, so implementing them would by necessity involve a fair amount of test writing and discussion with the Perl 6 design team.
The KeyHash, KeySet, and KeyBag classes are simply behavioral extension of their respective base classes, automatically deleting entries whenever their values reach a non-true value. However, Set and Bag still aren't implemented, and the spec documentation doesn't mention how to create them or how to access elements in them. Some thinking, discussion and test writing is required.
Another challenge faced in implementing the collection types is making sure that common idioms and algorithms surrounding sets, bags and hashes can be easily expressed. As prior art, the Java Collections Framework Tutorial http://java.sun.com/docs/books/tutorial/collections/ stands as an example of how a set of well-thought-out methods on a small number of interfaces and implementations can interact to create a rich set of possible uses. Where it makes sense to do so, inspiration can be had from that tutorial.
As to the Buf type, the specified parts are a more extensive, but deliberately vague http://gist.github.com/82837. Here too, implementation will raise a lot of questions during test writing and implementation. What we already know is that Buf will serve as a kind of "encoding-less" counterpart to Str; conversions to and from Buf will, respectively, decode and encode the character data. In fact, Buf will be the way in Perl 6 to read and store blobs of data without concern for their encoding. (The open() function was recently changed to read files as text/utf-8, so there's currently no way to read in files sans encoding. The addition of the Buf type would fix that.)
Work will begin as soon as the grant is approved. I expect to put enough effort into the tests and early implementation during June, so that I'll have a good grasp on the status of the remaining work by the end of that month, and hopefully be able to finish the grant by the beginning or middle of August.
End of June: Substantial progress on D1, D3 started.
Middle of July: D1 mostly complete, notable progress on D2.
Early August: D2 and D3 mostly complete.
Middle of August: Completion of all deliverables.
Blog posts will be made throughout the duration of the work on rakudo.org blog as well as my blog on use.perl.org.
All code, documentation and other relevant files that relate to Rakudo will be checked into the Rakudo repository. All code, documentation and other relevant files that relate to any Parrot fixes/additions arising as a result of this grant will be checked into the Parrot repository. All contributions to the specification and specification tests will be checked into the Pugs repository.
All work on produced as a result of this grant will be licensed under the Artistic License Version 2.0. I have signed the relevant CLA for The Perl Foundation regarding ownership.
I became interested in Perl 6 around 2004, was a sporadic committer during the Pugs days, and became seriously involved in Rakudo through the November wiki project. I became a committer to Parrot and Rakudo in September 2008. Since then, I've helped people apply patches, corrected obvious errors, implemented small features, and sometimes dived into the guts to track down the odd bug that bothered me enough. I've made over 70 commits each to the Perl 6 test suite and the Perl 6 specification, and 40 commits to Rakudo itself.
In my daily life I'm studying to become a bioinformatician (and have taken a fair share of programming courses at Uppsala University), as well as working half-time on bioinformatics software, also for Uppsala University.
I believe that my combination of Perl 6 experience and familiarity with the Rakudo Perl 6 internals, as well as my academic/professional background as a programmer and my contributions to Rakudo and Perl 6 so far, put me in a very strong position to successfully provide the deliverables detailed in this proposal.
Sweden
Swedish
$3000 USD
Yes
Patrick Michaud reports that he'll happily serve as grant manager for this project.
Hey! The above document had some coding errors, which are explained below:
- Around line 9:
-
Non-ASCII character seen before =encoding in 'Mäsak'. Assuming UTF-8