Parrot-GMP: Abandon Hope All Ye Who Enter Here

Good evening fellow parroters,

My blog posts will become increasingly technical as time goes on and if you're not into that kind of thing, then TL; DR - I'm working on it.

Still here? Good.

The main idea behind my project is to get usable bindings for GMP integer functions into Parrot. The GMP library is a good choice because it is free (as in beer and as in speech), stable, actively developed for 20 years, and generally fast: there are all kinds of optimizations for different architectures and compilers that there is absolutely no reason we should re-invent the wheel.

Here's a brief outline of the method to my madness: I'm currently writing a script that will read through gmp.h and give me the method signatures I want. This script will output these method signatures in a special format. One designed for another script called ncidef2pir which takes an NCI definition file and outputs boilerplate PIR code. I'll also be working on some scripts to cull an existing test suite from Math::GMPz (Perl 5) to get my tests and yet another script to get the great documentation from the GMP manual inlined into the PIR classes.

Every programmer should know that laziness is a virtue, especially if it means I can spend 5 hours automating a 5 minute task. But in all seriousness, this will save time if and when I expand to cover the remaining rational and decimal functions. Also, it's possible that some of these tools can be refactored to be used in other NCI / library binding type projects.

After all this automation magic happens, I'll be writing convenience classes in Winxed so there is a more friendly OO approach to GMP. That will be a great jumping off point to hit my last goal which is a functional example or tutorial in a higher level language like Rakudo. If there is time, I could even write a shiny wrapper class in NQP for the Rakudo folks to use.

And during this time I'll keep some notes so I can help produce some documentation for the NCI system. If I find documentation or test coverage is lacking, I'll try to add that in to Parrot as well.

Now for the real status update - I've got my script to read gmp.h mostly done. It currently reads the definitions and builds a hash of all the important information. I need to add more mappings from C types (and GMP specific structs) to NCI definitions. For example, a "void" in C should get converted into a "v" in the NCI definition. Since Monday is Memorial Day (a federal holiday in the US) I'll have plenty of time to get this done and maybe even refactor this logic into separate and reusable and tested modules. I'll update again when that is finished.