Skip to content

Instantly share code, notes, and snippets.

@teddziuba
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teddziuba/71c545f0a93f6e7131eb to your computer and use it in GitHub Desktop.
Save teddziuba/71c545f0a93f6e7131eb to your computer and use it in GitHub Desktop.
data transport by function definitions?
;; We define a product record as a series of explicitly-defined function return values.
;; - This only convey data, not execution
;; - It can reference itself in a sensible way
;; - Consumers aren't concerned about message formatting, simply whether or not
;; a given function is defined.
(defpoints SKU12345
(defpoint com.example.seller [this]
{:email "seller@example.com"
:name "Example Merchant Inc."})
(defpoint com.ebay.item.title [country] "Apple iPad")
(defpoint com.ebay.item.shipping-policy [:com.ebay.countries.germany]
{:processing-days 3
:shipping-type :expedited
:shipping-cost 0})
(defpoint com.ebay.item.shipping-policy [:com.ebay.countries.uk]
{:processing-days 3
:shipping-type :standard
:shipping-cost 10})
(defpoint com.ebay.item.paypal-email [country] (-> this com.example.seller :email)))
;; (com.ebay.title :com.ebay.countries.germany SKU12345) --> "Apple iPad"
;; (com.ebay.title :com.ebay.countries.uk SKU12345) --> "Apple iPad"
;; (com.ebay.title :com.ebay.countries.japan SKU12345) --> "Apple iPad"
;;
;; (com.ebay.item.shipping-policy SKU12345 :com.ebay.countries.uk) -->
;; {:processing-days 3
;; :shipping-type :standard
;; :shipping-cost 10}
;;
;; (com.ebay.item.seller-email SKU12345) --> "seller@example.com"
;;
;; (com.ebay.item.return-policy SKU12345) --> ERROR, undefined function point.
;; OR could use some default value here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment