Higher-Order Perl

by Mark Jason Dominus

Order Higher-Order Perl online from Powell's Books

Download full text here

There are three versions available. You have your choice of structure or presentation, but not both.

License reminder

Higher-Order Perl is copyright ©2005 by Elsevier Inc. Unauthorized reproduction or distribution is absolutely forbidden.

You may download the book for your personal use, but you may not distribute it to other people, either individually or by uploading it to a file-sharing service.

Although the text is available for free, Higher-Order Perl is not in the public domain and is not available under a free license of any sort. I distribute it from this web site by virtue of special permission from the publisher. You, most likely, do not have any such permission. If you distribute the files, you will be violating not only the law but also my personal wishes.

PDF

This is the publisher's own PDF proof of the second version, which was sent to the printers in August 2005.

This is better than the bootleg copies available from download sites in at least three ways:

Download the whole book.

**NEW** Reformatted with less marginal whitespace for mobile devices. Thanks to Joe McMahon for providing this version.

Download individual chapters

  1. (Front matter)
  2. Recursion and Callbacks
  3. Dispatch Tables
  4. Caching and Memoization
  5. Iterators
  6. From Recursion to Iterators
  7. Infinite Streams
  8. Higher-Order Functions and Currying
  9. Parsing
  10. Declarative Programming
  11. (Index)

How was this created?

I wrote the book using a markup language I programmed myself, called MOD, which you can see in the next section. I translated the MOD to HTML and sent HTML to the publisher, Morgan Kaufmann. As you should imagine, the HTML contained very little in the way of layout and typesetting instructions.

The typesetting company hand-translated my HTML to LaTeX, which they formatted and processed with LaTeX style files provided by the publisher. The interior layout and design, including creation of the style files, was done by an unsung genius named Julio Esperas, an employee of Morgan Kaufmann. If you think the interior of the book looks good, as I do, Julio Esperas is the person who deserves the credit.

The interior illustrations were created by a company called Dartmouth publishing, from my hand-drawn originals. There were several exchanges back and forth in which I told them to make the lines in the tree diagrams curved instead of straight, to make the clouds fluffier and the parabolas more elegant.

The cover was designed by a freelancer named Yvo Riezebos.

MOD

These are the original sources that I used to generate the manuscript draft that I first sent to the publisher. They are written in MOD, a variation on the "pod" markup in which Perl's documentation is written. It should be self-explanatory. If not, drop me a note.

The big drawback of this version is that it not only omits the corrections that were added between the first and second printings, but also the much more significant corrections that were added before the first printing.

The big advantage is structural markup and tests for the code.

Download the whole book.

Download individual chapters

  1. Recursion and Callbacks
  2. Dispatch Tables
  3. Caching and Memoization
  4. Iterators
  5. From Recursion to Iterators
  6. Infinite Streams
  7. Higher-Order Functions and Currying
  8. Parsing
  9. Declarative Programming

For the index, go here instead.

Mod package

Mod is a simple markup language, based on the POD system used to generate Perl's documentation.

The main desideratum for Mod was that I should be able to use the same sources to generate TeX to send to the compositors, HTML for the web version, and a plain text version output. (In the end I sent the HTML version to the compositors instead.) Also I wanted inline tests, so that when the book said “function foo returns 7” I could have an inline test that would check automatically that that the code, as written, did in fact return 7. I added some features I needed that POD didn't have, like a sequence to generate an index entry. And I fixed some things I didn't like about POD. (Bad spacing rules, too much implicit behavior, and instead of C<< $foo->method >> you write C<$foo-\>method>.)

Markdown hadn't been invented yet or I probably would have modified that instead of POD. Pandoc hadn't been invented yet or I probably would have used it.

But Mod didn't take long to make, and it worked well enough that it didn't get in the way while I wrote a book in it.

Source code is on GitHub. It is written in Perl.

Enjoy.

Order Higher-Order Perl online from Powell's Books


Return to: Mark Dominus blog | What's new page | Perl Paraphernalia | Higher-Order Perl

mjd-perl-hop+@plover.com