无法从when-let中的函数参数中识别出结构化的映射值名称

时间:2013-11-08 06:51:44

标签: clojure

我收到此编译错误说:Invalid token: function-name

(defn execute-task-from-message
  "Parses the message dictionary, gets the function-name and arguments-list
   and applys the function on the arguments"
  [{function-name: "function-name"
    arguments-list: "arguments-list"} msg]
  (when-let [task (ns-resolve
                   *ns*
                   (symbol
                   (str task-namespace function-name)))]
    (apply task arguments-list)))

我的代码出了什么问题?

1 个答案:

答案 0 :(得分:0)

你的论证解构中的一些额外的:是什么?如果你包含一些堆栈跟踪和更多的上下文,我可能会更具体:

user> (def task-namespace "where-does-this-come-from")
#'user/task-namespace
user> (defn execute-task-from-message
          "Parses the message dictionary, gets the function-name and arguments-list
           and applys the function on the arguments"
        [{function-name "function-name"
          arguments-list "arguments-list"} msg]
          (when-let [task (ns-resolve *ns*
                            (symbol 
                               (str task-namespace function-name)))]
           (apply task arguments-list))) 

#'user/execute-task-from-message