   joinFragmentArrays: (fragmentsList, joinStr) ->
     answer = []
     for fragments,i in fragmentsList
-      checkFragments fragments, @
       if i then answer.push @makeCode joinStr
       answer = answer.concat fragments
     answer


# Convert an array of CodeFragments into a string.
fragmentsToText = (fragments) ->
  checkFragments fragments
  (fragment.code for fragment in fragments).join('')

# Validates that `fragments` is an array of CodeFragment objects.
# If PARANOID is false, then this does nothing.
checkFragments = (fragments, node=null) ->
  if not PARANOID then return fragments

  nodeName = if node then " from #{node.constructor.name}" else ""
  if not fragments
    throw new Error("Fragments is null#{nodeName}: #{fragments}\n" )
  if fragments instanceof CodeFragment
    throw new Error("Expected array of fragments but found fragment#{nodeName}: #{fragments}\n" )
  for fragment, i in fragments
    if not (fragment instanceof CodeFragment)
      # This is not a fragment.
      inspected = (require 'util').inspect fragments
      nodeStr = if node then "node: #{node.toString()}\n" else ""
      throw new Error("Expected fragment: #{i} of #{fragments.length}#{nodeName}: #{fragment}\nFragments: #{inspected}\n#{nodeStr}")

  return fragments

#### Base


NO      = -> no
THIS    = -> this
NEGATE  = -> @negated = not @negated; this

#### CodeFragment

