nathanmarz/cascalog — pull request #256 by bhiles (2014-07-11 21:48:36+00:00)
Title: Remove Cascading platform from the base logic

To allow additional platforms to be added to Cascalog, we must first extract the Cascading platform from the base logic. This pull request begins the attempt to do that. Additionally, it begins adding in a Clojure platform, but that is barely built.

## How to use

To set the platform you need to use the **with-context** macro and specify which platform to use.

#### Cascading

(require '[cascalog.api :as api]
'[cascalog.logic.platform :as platform]
'[cascalog.cascading.platform])
(import 'cascalog.cascading.platform.CascadingPlatform)

(let [nums [[1][2]]]
(platform/with-context (CascadingPlatform.)
(api/??<- [?n] (nums ?n))))
=> ([1] [2])

### Clojure

(require '[cascalog.clojure.platform])
(import 'cascalog.clojure.platform.ClojurePlatform)

(let [nums [[1][2]]]
(platform/with-context (ClojurePlatform.)
(api/??<- [?n] (nums ?n))))
=> ([(1)] [(2)])

## Steps taken so far

* removed all cascading dependencies from the logic namespace (except for testing.clj)
* pulled in some functions from the cascading namespace into the logic.platform.clj since they appear platform agnostic (like compile-query)
* extended IPlatform to handle to-generator so we only need one dynamic var (*context*) and not two (*context* and *runner)
* built my really simple clojure platform and gave it a new namespace
* modified some tests so they continue using the Cascading platform. But many tests (about 21) currently fail and I will fix them once I'm more confident the direction I'm moving is the right one.

## Questions

* Is this approach moving in the right direction?
* Is with-context a good way to handle specifying which platform to use?
* Is creating EmptyPlatform a suitable solution to giving a dynamic var a default value without pulling in an implementation namespace?