 
   constructor: (variable, args) ->
     @children:  flatten [@variable: variable, @args: (args or [])]
+    @compile_splat_arguments: SplatNode.compile_mixed_array <- @, @args
     @prefix:    ''
 
   # Tag this invocation as creating a new instance.

      meth: "($temp = ${ @variable.source })${ @variable.last }"
    "$@prefix${meth}.apply($obj, ${ @compile_splat_arguments(o) })"

  # Converts arbitrary number of arguments, mixed with splats, to
  # a proper array to pass to an `.apply()` call
  compile_splat_arguments: (o) ->
    args: []
    i: 0
    for arg in @args
      code: arg.compile o
      if not (arg instanceof SplatNode)
        prev: args[i - 1]
        if i is 1 and prev.substr(0, 1) is '[' and prev.substr(prev.length - 1, 1) is ']'
          args[i - 1]: "${prev.substr(0, prev.length - 1)}, $code]"
          continue
        else if i > 1 and prev.substr(0, 9) is '.concat([' and prev.substr(prev.length - 2, 2) is '])'
          args[i - 1]: "${prev.substr(0, prev.length - 2)}, $code])"
          continue
        else
          code: "[$code]"
      args.push(if i is 0 then code else ".concat($code)")
      i += 1
    args.join('')


#### CurryNode


  # from the right-hand-side's corresponding array.
  compile_value: (o, name, index) ->
    "Array.prototype.slice.call($name, $index)"

# Utility function that converts arbitrary number of elements, mixed with 
# splats, to a proper array
SplatNode.compile_mixed_array: (list, o) ->
  args: []
  i: 0
  for arg in list
    code: arg.compile o
    if not (arg instanceof SplatNode)
      prev: args[i - 1]
      if i is 1 and prev.substr(0, 1) is '[' and prev.substr(prev.length - 1, 1) is ']'
        args[i - 1]: "${prev.substr(0, prev.length - 1)}, $code]"
        continue
      else if i > 1 and prev.substr(0, 9) is '.concat([' and prev.substr(prev.length - 2, 2) is '])'
        args[i - 1]: "${prev.substr(0, prev.length - 2)}, $code])"
        continue
      else
        code: "[$code]"
    args.push(if i is 0 then code else ".concat($code)")
    i += 1
  args.join('')

#### WhileNode

