 createFunction = (tag, behavior) ->
   (msg) ->
     switch msg
-      when sType then sNumber
+      when sType then sFunction
       when sBoolify then (x, y) -> x
       when sTag then tag
       when sBehavior then behavior

createSymbol = (value) ->
  (msg) ->
    switch msg
      when sType then sValue
      when sName then value
      when sBoolify then (x, y) -> x


cadddr = metacadr('cadddr')

intlistp =     (node) -> node.type == 'list'
intpairp =     (node) -> node.type == 'list' and ((node.value.length < 2) or node.value[1].node.type != 'list')
intsymbolp =   (node) -> node.type == 'symbol' or node instanceof Symbol
intnumberp =   (node) -> node.type == 'number'
intstringp =   (node) -> node.type == 'string'
intcommentp =  (node) -> node.type == 'comment'
intnvalu =     (node) -> node.value
intatomp =     (node) -> node.type in ['symbol', 'number', 'string']
intnullp =     (node) -> node.type == 'symbol' and node.value.name == 'null'
intmksymbols = (list) -> astSymbolsToLispSymbols(list)

# The hairness of this makes me doubt the wisdom of using Javascript.

sBehavior = new Symbol 'behavior'
sBoolean  = new Symbol 'boolean'
sBoolify  = new Symbol 'boolify'
sFunction = new Symbol 'function'
sSymbol   = new Symbol 'symbol'
sString   = new Symbol 'string'
sChars    = new Symbol 'chars'
sName     = new Symbol 'name'
sNumber   = new Symbol 'number'
sNull     = new Symbol 'null'
sTag      = new Symbol 'tag'
sType     = new Symbol 'type'
