Language-level support for automatic parallelism and lazy evaluation.
require 'pure' include Pure geometry = pure do def area(width, height) width*height end def width(border) 7 + border end def height(border) 5 + border end def border 2 end end # compute the area using 3 parallel threads puts geometry.compute(:area, :threads => 3) # => 63 # We've done this computation. puts((7 + 2)*(5 + 2)) # => 63
Pure is an importation of the pure functional paradigm into Ruby.
Method names and argument names have lexicographical meaning within a pure block. Above, the width argument to area corresponds by its literal name to the width method, for example.
pure returns a module which may be included into other pure blocks.
Implementation details are placed inside Pure::PurePrivate, making include Pure a hygienic operation.
Pure does not modify any of the standard classes.
The “ripper” parser is used if it exists, otherwise ruby_parser is used.
Pure has been tested on MRI 1.8.6, 1.8.7, 1.9.1 and the latest jruby.