4 Functions and Modules

4.3 Modules

4.3.1 What Modules Do

4.3.2 What Modules Don't Do

4.3.3 Creating a Module

4.3.4 Parameterized Modules

(defmodule (zaphod-rest-api request)
  (export (get-greeting 2)))

(defun get-greeting
  (('GET ())
   (tuple 'output '"Zaphod says 'hello!'"))
  (('GET _)
   (tuple 'output '"Zaphod says 'hello' to anything...")))
> (set req (: zaphod-rest-api new '"a request"))
#(zaphod-rest-api "a request")
> (call req 'get-greeting 'GET ())
#(output "Zaphod says 'hello!'")
> (call req 'get-greeting 'GET '"stuff")
#(output "Zaphod says 'hello' to anything...")
>

4.3.5 Projects

To see how modules are organized into projects, be sure to read the chapter on Development and Deployments.